-
Notifications
You must be signed in to change notification settings - Fork 6k
getRemoteUser() returns name of object implementing AuthenticatedPrincipal #9102
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
Conversation
@sjrd218 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@sjrd218 Thank you for signing the Contributor License Agreement! |
…rough to the toString() method which may render a string representation of the entire object rather than a username.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @sjrd218! I've left some feedback inline.
Also would you please format your commit to follow the contribution guidelines? Thanks!
@@ -106,6 +107,9 @@ public String getRemoteUser() { | |||
if (auth.getPrincipal() instanceof UserDetails) { | |||
return ((UserDetails) auth.getPrincipal()).getUsername(); | |||
} | |||
if (auth.getPrincipal() instanceof AuthenticatedPrincipal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that this is too narrow of a change to resolve #3357.
I wonder if this should instead do
if (auth instanceof AbstractAuthenticationToken) {
return auth.getName();
}
since AbstractAuthenticationToken
already has this same logic for AuthenticatedPrincipal
.
@@ -130,4 +135,18 @@ public void testRolePrefixNotAppliedIfRoleStartsWith() { | |||
assertThat(wrapper.isUserInRole("ROLE_FOOBAR")).isTrue(); | |||
} | |||
|
|||
@Test | |||
public void testGetRemoteUserStringWithAuthenticatedPrinciple() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you please change Principle
to Principal
?
@jzheaux Having trouble running gradle tasks for this project now. Constantly seeing:
|
Thanks, @sjrd218, will you please rebase and try again? There were some changes made yesterday to address that issue. |
Returns the name of the authenticated principle instead of falling through to the toString() method which may render a string representation of the entire object rather than a username.
This behavior is helpful in OAuth2 and Saml2 configurations.
Fixes: #3357