Skip to content

Conversation

blake-bauman
Copy link
Contributor

@blake-bauman blake-bauman commented Jun 27, 2025

Spring Security for Spring MVC allows for specifying multiple LogoutHandler implementations which get wrapped in a DelegatingLogoutHandler. Spring Security for WebFlux currently only allows a single ServerLogoutHandler implementation.

This PR puts both Spring MVC and Spring WebFlux on equal functionality when it comes to logout handlers.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 27, 2025
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, @blake-bauman, for the PR! In addition to my inline feedback, will you please add some tests to confirm that the new functionality works?

* @param logoutHandler
* @return the {@link LogoutSpec} to configure
*/
public LogoutSpec addLogoutHandler(ServerLogoutHandler logoutHandler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of exposing addLogoutHandler, would logout(Consumer<List<ServerLogoutHandler>> consumer) also service your needs? The reason this is nice it because it also allows you to remove values. Please see OneTimeTokenLogoutSpec#authenticationSuccessHandler for an example.

@jzheaux
Copy link
Contributor

jzheaux commented Jul 23, 2025

@blake-bauman, please also make sure to sign your commit and keep the commit title to about 50 characters, for example:

Support Multiple ServerLogoutHandlers

This commit adds support to ServerHttpSecurity for registering
multiple ServerLogoutHandlers. This is handy so that an application
does not need to re-supply any handlers already configured by
the DSL

@blake-bauman
Copy link
Contributor Author

I'm a little confused because I did sign it using the -s

Screenshot 2025-07-23 at 4 58 43 PM

@blake-bauman
Copy link
Contributor Author

blake-bauman commented Jul 24, 2025

@jzheaux I didn't see any existing tests for the Logout handler. Could you point to where they might be so that I can add on?

@blake-bauman
Copy link
Contributor Author

Instead of exposing addLogoutHandler, would logout(Consumer<List> consumer) also service your needs?

@jzheaux The reason I did it this way is because LogoutConfigurer for Servlet has addLogoutHandler() as public, and was attempting to match the spec for consistency. However, if you'd prefer that I switch to using Consumer<List<...>>, I can do that instead.

@jzheaux
Copy link
Contributor

jzheaux commented Jul 31, 2025

@blake-bauman, thanks for the updates. Here is the error message from the DCO bot:

Commit sha: [8fea725](https://github.com/spring-projects/spring-security/pull/17381/commits/8fea725b8c527233224b71bb5d01e3329f1feb41), Author: blake_bauman, Committer: blake_bauman; Expected "blake_bauman [[email protected]](mailto:[email protected])", but got "Blake Bauman [[email protected]](mailto:[email protected])".

It looks like it's complaining about "blake_bauman" being different from "Blake Bauman".

@jzheaux
Copy link
Contributor

jzheaux commented Jul 31, 2025

The reason I did it this way is because LogoutConfigurer for Servlet has addLogoutHandler() as public, and was attempting to match the spec for consistency.

I can see that, it makes sense. My guess is that the addLogoutHandler method is there bc it is an artifact from copy-pasting from LogoutHandlerConfigurer when LogoutSpec was first being written. That was before my time, though, so I'm not sure.

Either way, yes, the consumer is prefererred. This allows complete control over teh default list without also needing to add something like ObjectPostProcessor into the DSL.

@jzheaux
Copy link
Contributor

jzheaux commented Jul 31, 2025

@jzheaux I didn't see any existing tests for the Logout handler. Could you point to where they might be so that I can add on?

I don't think there are any yet. You can add them in LogoutSpecTests.

@jzheaux jzheaux self-assigned this Jul 31, 2025
@jzheaux jzheaux added in: config An issue in spring-security-config type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 31, 2025
@jzheaux jzheaux changed the title Allow multiple ServerLogoutHandler instances in WebFlux Allow multiple ServerLogoutHandler instances in ServerHttpSecurity Jul 31, 2025
@jzheaux jzheaux added this to the 7.0.x milestone Jul 31, 2025
@blake-bauman
Copy link
Contributor Author

@jzheaux Sorry for the delay. Been on vacation. Made the changes you requested.

@blake-bauman blake-bauman requested a review from jzheaux August 19, 2025 21:42
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, @blake-bauman! I've left some additional feedback inline.

Also, I think we are close enough to squash your commits. Will you please ensure that there are two commits:

  1. for this feature
  2. for the cleanup regarding the default logout handler null check (please see my inline comment)

Also, please double-check your DCO signature. The check is failing with the following error:

Commit sha: 8fea725, Author: blake_bauman, Committer: blake_bauman; Expected "blake_bauman [email protected]", but got "Blake Bauman [email protected]".

@jzheaux jzheaux added the status: waiting-for-feedback We need additional information before we can continue label Aug 22, 2025
Copy link
Contributor Author

@blake-bauman blake-bauman left a comment

Choose a reason for hiding this comment

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

Also, please double-check your DCO signature. The check is failing with the following error:

Not sure what's going on with the DCO. The latest commit has Signed-off-by: blake_bauman <[email protected]>

Also, I think we are close enough to squash your commits. Will you please ensure that there are two commits

Not quite sure how to do that since there's a rebase in the middle and I haven't been able to figure out how to squash without also squashing that one. (My git skills are admittedly weak.) Given the DCO issue and reverting the null change, would it make more sense if I simply closed this and created a new PR with just the one change? Or is squashing that rebase ok?

@jzheaux jzheaux force-pushed the multi-logout-handler-webflux branch 2 times, most recently from a8eb560 to 1c2c309 Compare September 2, 2025 21:31
@jzheaux
Copy link
Contributor

jzheaux commented Sep 2, 2025

No problem, @blake-bauman. DCO is a new thing for a lot of people and can be confusing.

The issue was that there were three commits, but only one of them was signed in a way that matched the commit author. The merge commit was unsigned and the initial commit used "Blake Bauman" instead of "blake_bauman".

To fix this, I rebased with main to remove the merge commit and then I squashed your two commits together, preserving the signature of the latest commit.

@blake-bauman blake-bauman force-pushed the multi-logout-handler-webflux branch from 2581a19 to d79c49d Compare September 3, 2025 00:23
This commit adds support to ServerHttpSecurity for registering
multiple ServerLogoutHandlers. This is handy so that an application
does not need to re-supply any handlers already configured by
the DSL.

Signed-off-by: blake_bauman <[email protected]>
@blake-bauman blake-bauman force-pushed the multi-logout-handler-webflux branch from e0161b0 to a45f40b Compare September 3, 2025 00:27
@blake-bauman blake-bauman requested a review from jzheaux September 3, 2025 00:27
@blake-bauman
Copy link
Contributor Author

Ok, I think I got it now and it's ready. I reverted the change to the returning null and it should be only 1 commit now, with a proper signoff.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 3, 2025
@jzheaux jzheaux modified the milestones: 7.0.x, 7.0.0-M3 Sep 5, 2025
@jzheaux jzheaux enabled auto-merge (rebase) September 5, 2025 17:37
@jzheaux
Copy link
Contributor

jzheaux commented Sep 5, 2025

Thanks again, @blake-bauman! This will merge into main once the build completes.

@blake-bauman
Copy link
Contributor Author

NP. Thanks for merging this!

@jzheaux jzheaux merged commit a4f813a into spring-projects:main Sep 5, 2025
6 checks passed
@blake-bauman blake-bauman deleted the multi-logout-handler-webflux branch October 7, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants