Skip to content

Commit

Permalink
Fix OAuth2 Error Code
Browse files Browse the repository at this point in the history
Closes gh-10319
  • Loading branch information
jzheaux committed Sep 28, 2021
1 parent cae8990 commit 1f919bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Expand Up @@ -90,7 +90,7 @@ public OAuth2TokenValidatorResult validate(Jwt jwt) {

private OAuth2Error createOAuth2Error(String 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");
}

Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.junit.Test;

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.jose.jws.JwsAlgorithms;

Expand Down Expand Up @@ -109,6 +110,7 @@ public void validateWhenConfiguredWithClockSkewThenValidatesUsingThatSkew() {
.collect(Collectors.toList());
// @formatter:on
assertThat(result.hasErrors()).isTrue();
assertThat(result.getErrors().iterator().next().getErrorCode()).isEqualTo(OAuth2ErrorCodes.INVALID_TOKEN);
assertThat(messages).contains("Jwt used before " + justOverOneDayFromNow);
}

Expand Down

0 comments on commit 1f919bc

Please sign in to comment.