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

Prevent Save @Transient Authentication with existing HttpSession #9993

Closed

Conversation

rwinch
Copy link
Member

@rwinch rwinch commented Jun 23, 2021

Previously, @Transient Authentication would get saved if an existing
HttpSession existed but it shouldn't.

This commit always prevents @Transient Authentication from being saved.

Closes gh-9992

@rwinch rwinch added in: web An issue in web modules (web, webmvc) type: bug A general bug labels Jun 23, 2021
@rwinch rwinch added this to the 5.6.0-M1 milestone Jun 23, 2021
@rwinch rwinch requested a review from jzheaux June 23, 2021 19:31
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.

Looks good, @rwinch. I left a polish suggestion inline.

Previously, @transient Authentication would get saved if an existing
HttpSession existed but it shouldn't.

This commit always prevents @transient Authentication from being saved.

Closes spring-projectsgh-9992
@rwinch rwinch force-pushed the gh-9992-transient-with-session branch from 2c01e41 to 87f38d8 Compare June 28, 2021 21:19
@eleftherias eleftherias modified the milestones: 5.6.0-M1, 5.6.0-M2 Jul 19, 2021
@rwinch rwinch modified the milestones: 5.6.0-M2, 5.6.0-M3 Aug 16, 2021
@sjohnr sjohnr modified the milestones: 5.6.0-M3, 5.6.0-RC1 Sep 20, 2021
@rwinch rwinch modified the milestones: 5.6.0-RC1, 5.6.0 Oct 19, 2021
@rwinch rwinch modified the milestones: 5.6.0, 5.7.0-M1 Nov 12, 2021
@rwinch
Copy link
Member Author

rwinch commented Nov 16, 2021

Merged via 96a6fef

@jawherallani
Copy link

jawherallani commented Jul 28, 2022

This breaks my app when I switched from 5.6.6 to 5.7, as JwtAuthenticationToken which has @transient is being used:
the regular flow with 5.6.6:

  • request A (websocket handshake) is fired, no http session yet, it fails and will retry
  • api request B includes a bearer token in the headers, JwtAuthenticationToken authentication takes place and is then used to attach the SecurityContext on the http session as SPRING_SECURITY_CONTEXT attribute.
  • request A, being retried, uses the http session to get the SecurityContext that was just saved and so is authenticated.

This flow breaks because of the isTransient method now.

Is there something wrong with this flow? and why should @transient Authentication be prevented from saving? Any suggestions?

doba16 pushed a commit to doba16/spring-authorization-server that referenced this pull request Apr 21, 2023
BlueDream0911 pushed a commit to BlueDream0911/spring-authorization-server that referenced this pull request Sep 13, 2024
BlueDream0911 added a commit to BlueDream0911/spring-authorization-server that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HttpSecurityContextRepository saves @Transient Authentication if HttpSession already exists
5 participants