Skip to content

Commit 4df9b45

Browse files
committed
Fix OAuth2 Error Code
Closes gh-10319
1 parent 0206001 commit 4df9b45

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
@@ -90,7 +90,7 @@ public OAuth2TokenValidatorResult validate(Jwt jwt) {
9090

9191
private OAuth2Error createOAuth2Error(String reason) {
9292
this.logger.debug(reason);
93-
return new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST, reason,
93+
return new OAuth2Error(OAuth2ErrorCodes.INVALID_TOKEN, reason,
9494
"https://tools.ietf.org/html/rfc6750#section-3.1");
9595
}
9696

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
@@ -28,6 +28,7 @@
2828
import org.junit.Test;
2929

3030
import org.springframework.security.oauth2.core.OAuth2Error;
31+
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
3132
import org.springframework.security.oauth2.core.OAuth2TokenValidatorResult;
3233
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
3334

@@ -109,6 +110,7 @@ public void validateWhenConfiguredWithClockSkewThenValidatesUsingThatSkew() {
109110
.collect(Collectors.toList());
110111
// @formatter:on
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)