Change default authority for oauth2Login()
Previously, the default authority was ROLE_USER when using oauth2Login() for both OAuth2 and OIDC providers. * Default authority for OAuth2UserAuthority is now OAUTH2_USER * Default authority for OidcUserAuthority is now OIDC_USER Documentation has been updated to include this implementation detail. Closes gh-7856
This commit is contained in:
@@ -302,7 +302,8 @@ The UserInfo Endpoint includes a number of configuration options, as described i
|
||||
[[webflux-oauth2-login-advanced-map-authorities]]
|
||||
=== Mapping User Authorities
|
||||
|
||||
After the user successfully authenticates with the OAuth 2.0 Provider, the `OAuth2User.getAuthorities()` (or `OidcUser.getAuthorities()`) may be mapped to a new set of `GrantedAuthority` instances, which will be supplied to `OAuth2AuthenticationToken` when completing the authentication.
|
||||
After the user successfully authenticates with the OAuth 2.0 Provider, the `OAuth2User.getAuthorities()` (or `OidcUser.getAuthorities()`) contains a list of granted authorities populated from `OAuth2UserRequest.getAccessToken().getScopes()` and prefixed with `SCOPE_`.
|
||||
These granted authorities may be mapped to a new set of `GrantedAuthority` instances, which will be supplied to `OAuth2AuthenticationToken` when completing the authentication.
|
||||
|
||||
[TIP]
|
||||
`OAuth2AuthenticationToken.getAuthorities()` is used for authorizing requests, such as in `hasRole('USER')` or `hasRole('ADMIN')`.
|
||||
@@ -316,6 +317,8 @@ There are a couple of options to choose from when mapping user authorities:
|
||||
[[webflux-oauth2-login-advanced-map-authorities-grantedauthoritiesmapper]]
|
||||
==== Using a GrantedAuthoritiesMapper
|
||||
|
||||
The `GrantedAuthoritiesMapper` is given a list of granted authorities which contains a special authority of type `OAuth2UserAuthority` and the authority string `OAUTH2_USER` (or `OidcUserAuthority` and the authority string `OIDC_USER`).
|
||||
|
||||
Register a `GrantedAuthoritiesMapper` `@Bean` to have it automatically applied to the configuration, as shown in the following example:
|
||||
|
||||
.Granted Authorities Mapper Configuration
|
||||
|
||||
@@ -425,7 +425,8 @@ The UserInfo Endpoint includes a number of configuration options, as described i
|
||||
[[oauth2login-advanced-map-authorities]]
|
||||
=== Mapping User Authorities
|
||||
|
||||
After the user successfully authenticates with the OAuth 2.0 Provider, the `OAuth2User.getAuthorities()` (or `OidcUser.getAuthorities()`) can be mapped to a new set of `GrantedAuthority` instances, which are supplied to `OAuth2AuthenticationToken` when completing the authentication.
|
||||
After the user successfully authenticates with the OAuth 2.0 Provider, the `OAuth2User.getAuthorities()` (or `OidcUser.getAuthorities()`) contains a list of granted authorities populated from `OAuth2UserRequest.getAccessToken().getScopes()` and prefixed with `SCOPE_`.
|
||||
These granted authorities can be mapped to a new set of `GrantedAuthority` instances, which are supplied to `OAuth2AuthenticationToken` when completing the authentication.
|
||||
|
||||
[TIP]
|
||||
`OAuth2AuthenticationToken.getAuthorities()` is used for authorizing requests, such as in `hasRole('USER')` or `hasRole('ADMIN')`.
|
||||
@@ -439,6 +440,8 @@ There are a couple of options to choose from when mapping user authorities:
|
||||
[[oauth2login-advanced-map-authorities-grantedauthoritiesmapper]]
|
||||
==== Using a GrantedAuthoritiesMapper
|
||||
|
||||
The `GrantedAuthoritiesMapper` is given a list of granted authorities which contains a special authority of type `OAuth2UserAuthority` and the authority string `OAUTH2_USER` (or `OidcUserAuthority` and the authority string `OIDC_USER`).
|
||||
|
||||
Provide an implementation of `GrantedAuthoritiesMapper` and configure it, as follows:
|
||||
|
||||
.Granted Authorities Mapper Configuration
|
||||
|
||||
Reference in New Issue
Block a user