Skip to content
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

Expose user name attribute name in OAuth2UserAuthority #15012

Closed

Conversation

filiphr
Copy link
Contributor

@filiphr filiphr commented May 6, 2024

We are using custom GrantedAuthoritiesMapper that is doing some custom loading of attributes based on the OAuth2UserAuthority. We've had some request to do something based on the user name. Currently, there is no easy way to access the configured username attribute name.

The goal of this PR is to expose this information directly in the OAuth2UserAuthority and this make it easy to get the username from the attributes.

An alternative could also be to expose getUserName and just use the userNameAttributeName in the OAuth2UserAuthority.

I hope that you'll consider this PR, if there is anything that you think should be added or done better please let me know

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 6, 2024
@filiphr
Copy link
Contributor Author

filiphr commented May 28, 2024

Can someone from the Spring Security team have a look at this? If this is something that you are not interested in then let me know and we can close it.

@sjohnr sjohnr self-assigned this May 30, 2024
@sjohnr sjohnr added type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged labels May 30, 2024
@sjohnr
Copy link
Member

sjohnr commented May 30, 2024

Thanks @filiphr! I'll be taking a look at this and send any feedback in the next few days. Overall it seems reasonable and a nice enhancement so I think we should be able to accept it.

sjohnr added a commit that referenced this pull request Jun 3, 2024
@sjohnr
Copy link
Member

sjohnr commented Jun 3, 2024

Thanks @filiphr! This is now merged as 99aee99 with minor polish 7c45ebd.

@sjohnr sjohnr closed this Jun 3, 2024
@sjohnr sjohnr modified the milestone: 6.4.0-M1 Jun 3, 2024
sjohnr added a commit that referenced this pull request Jun 4, 2024
@filiphr
Copy link
Contributor Author

filiphr commented Jun 10, 2024

Thanks a lot for merging this @sjohnr

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) type: enhancement A general enhancement
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants