Skip to content

JwtGrantedAuthoritiesConverter should allow configuring the authorities claim name #7100

Closed
@jzheaux

Description

@jzheaux

Related to #6945

It would be nice if an application could indicate a custom claim name for GrantedAuthoritys without creating a custom converter.

Something like:

JwtGrantedAuthoritiesConverter converter = new JwtGrantedAuthoritiesConverter();
converter.setAuthoritiesClaimName("authorities");

Would be easier to do than:

Converter<Jwt, List<GrantedAuthorities>> converter = jwt -> {
    List<String> authorities = (List<String>) jwt.getClaim("authorities");
    return authorities.stream()
        .map(authority -> "SCOPE_" + authority)
        .map(SimpleGrantedAuthority::new)
        .collect(Collectors.toList());
};

So, let's add a setter to JwtGrantedAuthoritiesConverter called setAuthoritiesClaimName so that the converter knows which claim to look for.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions