-
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: enhancementA general enhancementA general enhancement
Milestone
Description
Summary
I'd like the ability to modify Reactive OAuth2Login's authoritiesMapper.
Actual Behavior
Can't find a suitable API to configure this. There's an equivalent for the Servlet HttpSecurity but not for Reactive equivalent.
Digging into the source code further seem to suggest that OAuth2LoginAuthenticationProvider (Servlet) have setAuthoritiesMapper, and OidcAuthorizationCodeReactiveAuthenticationManager (Reactive) does not have setAuthoritiesMapper
Expected Behavior
I expect I can do something similar for Reactive OAuth2Login
Configuration
Servlet HttpSecurity
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(a -> a
.antMatchers("/", "/error", "/webjars/**").permitAll()
.anyRequest().authenticated()
)
.exceptionHandling(e -> e
.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
)
.logout(l -> l
.logoutSuccessUrl("/").permitAll()
)
.oauth2Login().userInfoEndpoint().userAuthoritiesMapper(new GrantedAuthoritiesMapper() {
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
return null;
}
});
// @formatter:on
}
Reactive
@Bean
protected SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
return http
.authorizeExchange(a -> a
.pathMatchers("/static/**", "/", "/error", "/webjars/**", "/login/**").permitAll()
.anyExchange().authenticated()
)
.exceptionHandling(e -> e
.authenticationEntryPoint(new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED))
)
.logout().logoutUrl("/")
.and()
.oauth2Login().userInfoEndpoint().userAuthoritiesMapper(new GrantedAuthoritiesMapper() {
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
return null;
}
}) // DOES NOT COMPILE
.and().build();
// @formatter:on
}
Version
5.2.1.RELEASE
Sample
Will provide soon if it gives further clarity
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: enhancementA general enhancementA general enhancement