spring-projects / spring-projects/spring-security
Dedicated API for extracting roles from Oidc User flow
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the OAuth2UserService customization described in the linked reference documentation and inspect the OidcUser flow entry points in Spring Security. Define the dedicated authorities-extraction API proposed in the issue, then verify that custom OIDC role representations can be converted without requiring a replacement OAuth2UserService.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, authorization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100