|
|
|
@ -18,7 +18,6 @@ package org.springframework.security.oauth2.server.authorization.authentication; |
|
|
|
import java.security.Principal; |
|
|
|
import java.security.Principal; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
@ -147,7 +146,7 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica |
|
|
|
JoseHeader.Builder headersBuilder = JwtUtils.headers(); |
|
|
|
JoseHeader.Builder headersBuilder = JwtUtils.headers(); |
|
|
|
JwtClaimsSet.Builder claimsBuilder = JwtUtils.accessTokenClaims( |
|
|
|
JwtClaimsSet.Builder claimsBuilder = JwtUtils.accessTokenClaims( |
|
|
|
registeredClient, issuer, authorization.getPrincipalName(), |
|
|
|
registeredClient, issuer, authorization.getPrincipalName(), |
|
|
|
excludeOpenidIfNecessary(authorizedScopes)); |
|
|
|
authorizedScopes); |
|
|
|
|
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
// @formatter:off
|
|
|
|
JwtEncodingContext context = JwtEncodingContext.with(headersBuilder, claimsBuilder) |
|
|
|
JwtEncodingContext context = JwtEncodingContext.with(headersBuilder, claimsBuilder) |
|
|
|
@ -169,7 +168,7 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica |
|
|
|
|
|
|
|
|
|
|
|
OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, |
|
|
|
OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, |
|
|
|
jwtAccessToken.getTokenValue(), jwtAccessToken.getIssuedAt(), |
|
|
|
jwtAccessToken.getTokenValue(), jwtAccessToken.getIssuedAt(), |
|
|
|
jwtAccessToken.getExpiresAt(), excludeOpenidIfNecessary(authorizedScopes)); |
|
|
|
jwtAccessToken.getExpiresAt(), authorizedScopes); |
|
|
|
|
|
|
|
|
|
|
|
OAuth2RefreshToken refreshToken = null; |
|
|
|
OAuth2RefreshToken refreshToken = null; |
|
|
|
if (registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN)) { |
|
|
|
if (registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN)) { |
|
|
|
@ -245,15 +244,6 @@ public class OAuth2AuthorizationCodeAuthenticationProvider implements Authentica |
|
|
|
registeredClient, clientPrincipal, accessToken, refreshToken, additionalParameters); |
|
|
|
registeredClient, clientPrincipal, accessToken, refreshToken, additionalParameters); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Set<String> excludeOpenidIfNecessary(Set<String> scopes) { |
|
|
|
|
|
|
|
if (!scopes.contains(OidcScopes.OPENID)) { |
|
|
|
|
|
|
|
return scopes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
scopes = new HashSet<>(scopes); |
|
|
|
|
|
|
|
scopes.remove(OidcScopes.OPENID); |
|
|
|
|
|
|
|
return scopes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean supports(Class<?> authentication) { |
|
|
|
public boolean supports(Class<?> authentication) { |
|
|
|
return OAuth2AuthorizationCodeAuthenticationToken.class.isAssignableFrom(authentication); |
|
|
|
return OAuth2AuthorizationCodeAuthenticationToken.class.isAssignableFrom(authentication); |
|
|
|
|