-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Open
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
Description
Summary
Today, in order to extract Spring Security roles from custom role representations in the Oidc User flow, code needs to fall back to implementing an OAuth2UserService
:
public MyRoleExtractingOidcUserService implements OAuth2UserService<OidcUserRequest, OidcUser> {
private final OidcUserService delegate;
// ...
public OidcUser loadUser(OidcUserRequest request) {
OidcUser user = delegate.loadUser(reqest);
Collection<? extends GrantedAuthority> authorities =
// extract authorities using request and user objects
return new DefaultOidcUser(authorities, ...);
}
This follows from the reference documentation [1].
Would be nice to have a dedicated authorities extractor:
interface OAuth2UserAuthoritiesExtractor<R extends OAuth2UserRequest, U extends OAuth2User> {
Collection<? extends GrantedAuthority> extractAuthorities(R request, U user);
}
Additional Info
This is born out of some observations from @thomasdarimont in a OAuth github sample.
tunaranch, zeratul021, XhstormR, dawi, husam-e and 1 more
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