Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -282,8 +284,13 @@ public Authentication authenticate(Authentication authentication) throws Authent
Set<String> currentAuthorizedScopes = (currentAuthorizationConsent != null)
? currentAuthorizationConsent.getScopes() : null;

Map<String, Object> additionalParameters = new HashMap<>();
if (pushedAuthorization != null) {
additionalParameters.put(OAuth2ParameterNames.SCOPE, authorizationRequest.getScopes());
}

return new OAuth2AuthorizationConsentAuthenticationToken(authorizationRequest.getAuthorizationUri(),
registeredClient.getClientId(), principal, state, currentAuthorizedScopes, null);
registeredClient.getClientId(), principal, state, currentAuthorizedScopes, additionalParameters);
}

OAuth2TokenContext tokenContext = createAuthorizationCodeTokenContext(authorizationCodeRequestAuthentication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,20 @@ private void sendAuthorizationConsent(HttpServletRequest request, HttpServletRes

String clientId = authorizationConsentAuthentication.getClientId();
Authentication principal = (Authentication) authorizationConsentAuthentication.getPrincipal();
Set<String> requestedScopes = authorizationCodeRequestAuthentication.getScopes();
Set<String> authorizedScopes = authorizationConsentAuthentication.getScopes();
String state = authorizationConsentAuthentication.getState();

Set<String> requestedScopes;
String requestUri = (String) authorizationCodeRequestAuthentication.getAdditionalParameters()
.get(OAuth2ParameterNames.REQUEST_URI);
if (StringUtils.hasText(requestUri)) {
requestedScopes = (Set<String>) authorizationConsentAuthentication.getAdditionalParameters()
.get(OAuth2ParameterNames.SCOPE);
}
else {
requestedScopes = authorizationCodeRequestAuthentication.getScopes();
}

if (hasConsentUri()) {
String redirectUri = UriComponentsBuilder.fromUriString(resolveConsentUri(request))
.queryParam(OAuth2ParameterNames.SCOPE, String.join(" ", requestedScopes))
Expand Down
Loading