mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-30 15:52:15 +00:00
Fix OAuth2 Error Code
Closes gh-10319
This commit is contained in:
parent
02060015a5
commit
4df9b4547f
@ -90,7 +90,7 @@ public final class JwtTimestampValidator implements OAuth2TokenValidator<Jwt> {
|
|||||||
|
|
||||||
private OAuth2Error createOAuth2Error(String reason) {
|
private OAuth2Error createOAuth2Error(String reason) {
|
||||||
this.logger.debug(reason);
|
this.logger.debug(reason);
|
||||||
return new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST, reason,
|
return new OAuth2Error(OAuth2ErrorCodes.INVALID_TOKEN, reason,
|
||||||
"https://tools.ietf.org/html/rfc6750#section-3.1");
|
"https://tools.ietf.org/html/rfc6750#section-3.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import java.util.stream.Collectors;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.security.oauth2.core.OAuth2Error;
|
import org.springframework.security.oauth2.core.OAuth2Error;
|
||||||
|
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
|
||||||
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
|
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
|
||||||
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
|
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
|
||||||
|
|
||||||
@ -109,6 +110,7 @@ public class JwtTimestampValidatorTests {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
assertThat(result.hasErrors()).isTrue();
|
assertThat(result.hasErrors()).isTrue();
|
||||||
|
assertThat(result.getErrors().iterator().next().getErrorCode()).isEqualTo(OAuth2ErrorCodes.INVALID_TOKEN);
|
||||||
assertThat(messages).contains("Jwt used before " + justOverOneDayFromNow);
|
assertThat(messages).contains("Jwt used before " + justOverOneDayFromNow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user