-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: bugA general bugA general bug
Milestone
Description
Describe the bug
Scope mapping handling changed with #12112.
2915a70#diff-73bd44f873d78e3d71e6a0fa18644a304d562a4a9fd2e303e913f6ed20a0ad16R78-R83
OidcAuthorizationCodeAuthenticationProvider.authenticate()
callsOidcAuthorizationCodeAuthenticationProvider.getResponse()
)DefaultAuthorizationCodeTokenResponseClient.getTokenResponse
does NOT add the scopes anymore. If no scopes are returned by default by the IdP, the scopes list is empty.- The comment
If AccessTokenResponse.scope is empty, then we assume all requested scopes were granted.
seems to say something completely different.
- The comment
- Back in
OidcAuthorizationCodeAuthenticationProvider.authenticate()
the user info has to be loaded:this.userService.loadUser()
. OidcUserService.loadUser
callsthis.shouldRetrieveUserInfo(userRequest)
which returnsfalse
now, because the scopes (userRequest.getAccessToken().getScopes()
) is empty.- Because of this the userInfo is not loaded (it is
null
) and can't be used for example in theuserAuthoritiesMapper
.
To Reproduce
Our scopes are configured like this:
spring.security.oauth2.client.registration.default.scope=openid,profile,entitlements
Use the userAuthoritiesMapper
with a token-uri endpoint that doesn't return a list of scopes.
http.oauth2Login()
.userInfoEndpoint().userAuthoritiesMapper(this.userAuthoritiesMapper());
In the authorities mapper try to use the oidcUserAuthority.getUserInfo()
(which is now null).
Expected behavior
oidcUserAuthority.getUserInfo()
should not be null
.
Sample
No sample yet.
Ping @sjohnr
tobiaskrauss and timomeinen
Metadata
Metadata
Assignees
Labels
in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: bugA general bugA general bug