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

Updates for #6911 and #6918 #1131

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Updates for #6911 and #6918 #1131

wants to merge 5 commits into from

Conversation

jvz
Copy link
Contributor

@jvz jvz commented Jan 3, 2024

Contains two small commits separated by the two relevant issues:

jvz added 2 commits January 3, 2024 12:20
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
@jvz jvz requested review from cfieber and jonsie as code owners January 3, 2024 19:15
"anonymous",
"anonymous",
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")));
SpinnakerUsers.ANONYMOUS,
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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);

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

jvz added 2 commits January 8, 2024 12:58
This extracts some constants for use in configuring anonymous
authentication.
@mattgogerly
Copy link
Member

@Mergifyio update

Copy link
Contributor

mergify bot commented Apr 17, 2024

update

✅ Branch has been successfully updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants