Skip to content

Add setter for authorities claim name in JwtGrantedAuthoritiesConverter #7271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2019

Conversation

andifalk
Copy link
Contributor

Fixes gh-7100

Prior to this change authorities are always mapped using well known
claim names ('scp' or 'scope'). To change this default behaviour the
converter had to be replaced completely with a custom one.
This commit adds an additional setter to configure a custom
claim name like for example 'roles' to map authorities.
Without specifying a custom claim name
the default claims to be used still remains to
the well known ones ('scp' and 'scope').

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 16, 2019
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @andifalk! I've left some feedback inline.

Prior to this change authorities are always mapped using well known
claim names ('scope' or 'scp'). To change this default behaviour the
converter had to be replaced completely with a custom one.
This commit adds an additional setter to configure a custom
claim name like e.g. 'roles'. Without specifying a custom claim name
the default claims to be used still remains to the well known ones.
This way the authorities can be mapped according to customized
token claims.

Fixes spring-projectsgh-7100
Some negative test cases were missing. Added these to have
full test coverage for JwtGrantedAuthoritiesConverter.
@jzheaux jzheaux self-assigned this Aug 20, 2019
@jzheaux jzheaux added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: duplicate A duplicate of another issue type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 20, 2019
@jzheaux jzheaux added this to the 5.2.0.RC1 milestone Aug 20, 2019
@jzheaux jzheaux merged commit 766c443 into spring-projects:master Aug 20, 2019
@jzheaux
Copy link
Contributor

jzheaux commented Aug 20, 2019

Thanks for another PR, @andifalk! This is now merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JwtGrantedAuthoritiesConverter should allow configuring the authorities claim name
3 participants