-
Notifications
You must be signed in to change notification settings - Fork 591
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
Updates for #6911 and #6918 #1131
base: master
Are you sure you want to change the base?
Conversation
Spring Security uses an anonymous principal of "anonymousUser" by default which does not match the rest of Spinnaker where the anonymous user is expected to have the username "anonymous". This ensures that fiat-api code consistently uses the same anonymous principal. Related to spinnaker/spinnaker#6918
"anonymous", | ||
"anonymous", | ||
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"))); | ||
SpinnakerUsers.ANONYMOUS, |
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.
notes for reviewers -- the new code looks like it does exactly the same thing as the old code, so this is "just" a refactor.
@@ -143,6 +144,8 @@ protected void configure(HttpSecurity http) throws Exception { | |||
.exceptionHandling() | |||
.and() | |||
.anonymous() | |||
// match the same anonymous userid as expected elsewhere |
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.
How is this different from .anonymous()
above? Can you write a test that demonstrates this?
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.
The default settings in this DSL set the principal to the string anonymousUser
. The DSL is tricky to test since it's mostly a DSL for setting up beans.
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.
So using the updated Spring Security DSL, this whole method would look more like the following:
http.servletApi(Customizer.withDefaults())
.exceptionHandling(Customizer.withDefaults())
.anonymous(anonymous -> anonymous.principal(SpinnakerUsers.ANONYMOUS))
.addFilterBefore(
new FiatAuthenticationFilter(fiatStatus, authenticationConverter),
AnonymousAuthenticationFilter.class);
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 didn't see before. .principal(SpinnakerUsers.ANONYMOUS)
modifies how .anonymous()
works...it's not another mechanism in addition to it.
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'll figure out some sort of test.
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.
Turns out testing this is futile. I've extracted some constants to make this more consistent.
This extracts some constants for use in configuring anonymous authentication.
@Mergifyio update |
✅ Branch has been successfully updated |
Contains two small commits separated by the two relevant issues:
anonymous
username spinnaker#6918 (small change which required similar dependency updates)