@ -6851,13 +6851,21 @@ The UserInfo Endpoint includes a number of configuration options, as described i
@@ -6851,13 +6851,21 @@ The UserInfo Endpoint includes a number of configuration options, as described i
==== Mapping User Authorities
After the user successfully authenticates with the OAuth 2.0 Provider,
the `OAuth2User.getAuthorities()` may be mapped to a new set of `GrantedAuthority` instances, which are then supplied to `OAuth2AuthenticationToken`.
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.
[TIP]
`OAuth2AuthenticationToken.getAuthorities()` is used for authorizing requests, such as in `hasRole('USER')` or `hasRole('ADMIN')`.
In order to map user authorities, you need to provide an implementation of `GrantedAuthoritiesMapper`
and configure it as shown in the following example:
There are a couple of options to choose from when mapping user authorities:
* <<oauth2login-advanced-map-authorities-grantedauthoritiesmapper,Using a `GrantedAuthoritiesMapper`>>
* <<oauth2login-advanced-map-authorities-oauth2userservice,Delegation-based strategy with `OAuth2UserService`>>
Provide an implementation of `GrantedAuthoritiesMapper` and configure it as shown in the following example:
[source,java]
----
@ -6904,6 +6912,56 @@ public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter {
@@ -6904,6 +6912,56 @@ public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter {