|
@@ -35,7 +35,6 @@ import org.springframework.security.crypto.keygen.StringKeyGenerator;
|
|
|
import org.springframework.security.oauth2.core.AuthorizationGrantType;
|
|
|
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
|
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
|
|
-import org.springframework.security.oauth2.core.OAuth2Error;
|
|
|
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
|
|
|
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
|
|
|
import org.springframework.security.oauth2.core.OAuth2TokenType;
|
|
@@ -136,15 +135,15 @@ public final class OAuth2RefreshTokenAuthenticationProvider implements Authentic
|
|
|
OAuth2Authorization authorization = this.authorizationService.findByToken(
|
|
|
refreshTokenAuthentication.getRefreshToken(), OAuth2TokenType.REFRESH_TOKEN);
|
|
|
if (authorization == null) {
|
|
|
- throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_GRANT));
|
|
|
+ throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT);
|
|
|
}
|
|
|
|
|
|
if (!registeredClient.getId().equals(authorization.getRegisteredClientId())) {
|
|
|
- throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_CLIENT));
|
|
|
+ throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_CLIENT);
|
|
|
}
|
|
|
|
|
|
if (!registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN)) {
|
|
|
- throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.UNAUTHORIZED_CLIENT));
|
|
|
+ throw new OAuth2AuthenticationException(OAuth2ErrorCodes.UNAUTHORIZED_CLIENT);
|
|
|
}
|
|
|
|
|
|
OAuth2Authorization.Token<OAuth2RefreshToken> refreshToken = authorization.getRefreshToken();
|
|
@@ -152,7 +151,7 @@ public final class OAuth2RefreshTokenAuthenticationProvider implements Authentic
|
|
|
// As per https://tools.ietf.org/html/rfc6749#section-5.2
|
|
|
// invalid_grant: The provided authorization grant (e.g., authorization code,
|
|
|
// resource owner credentials) or refresh token is invalid, expired, revoked [...].
|
|
|
- throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_GRANT));
|
|
|
+ throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT);
|
|
|
}
|
|
|
|
|
|
// As per https://tools.ietf.org/html/rfc6749#section-6
|
|
@@ -161,7 +160,7 @@ public final class OAuth2RefreshTokenAuthenticationProvider implements Authentic
|
|
|
Set<String> scopes = refreshTokenAuthentication.getScopes();
|
|
|
Set<String> authorizedScopes = authorization.getAttribute(OAuth2Authorization.AUTHORIZED_SCOPE_ATTRIBUTE_NAME);
|
|
|
if (!authorizedScopes.containsAll(scopes)) {
|
|
|
- throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_SCOPE));
|
|
|
+ throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_SCOPE);
|
|
|
}
|
|
|
if (scopes.isEmpty()) {
|
|
|
scopes = authorizedScopes;
|