Skip to content

Commit dc95d8d

Browse files
committed
Fix OAuth2 Error Code
Closes gh-10319
1 parent 31cc0b8 commit dc95d8d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtTimestampValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public OAuth2TokenValidatorResult validate(Jwt jwt) {
9595
private OAuth2Error createOAuth2Error(String reason) {
9696
logger.debug(reason);
9797
return new OAuth2Error(
98-
OAuth2ErrorCodes.INVALID_REQUEST,
98+
OAuth2ErrorCodes.INVALID_TOKEN,
9999
reason,
100100
"https://tools.ietf.org/html/rfc6750#section-3.1");
101101
}

oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtTimestampValidatorTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.junit.Test;
2828

2929
import org.springframework.security.oauth2.core.OAuth2Error;
30+
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
3031
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
3132
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
3233

@@ -109,6 +110,7 @@ public void validateWhenConfiguredWithClockSkewThenValidatesUsingThatSkew() {
109110
result.getErrors().stream().map(OAuth2Error::getDescription).collect(Collectors.toList());
110111

111112
assertThat(result.hasErrors()).isTrue();
113+
assertThat(result.getErrors().iterator().next().getErrorCode()).isEqualTo(OAuth2ErrorCodes.INVALID_TOKEN);
112114
assertThat(messages).contains("Jwt used before " + justOverOneDayFromNow);
113115

114116
}

0 commit comments

Comments
 (0)