-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Switching users creates user sessions #13435
Comments
Hi @filiphr, thanks for the report.
The filters that you mentioned are stateless filters or filters meant to be extended, that is one reason that they cannot assume you are using sessions.
I don't think I agree here because switching users typically implies a user is logged in and has an authenticated session that needs to change across a period of requests. In a stateless arrangement, there is no need to "switch the user", one simply provides different creds on each request. It is not intuitive if I need to set the If you have your own What do you think? |
What is the difference between the
We can agree to disagree on this one. Switching users is usually done for impersonating someone, which means that you do not have the credentials for the user you are trying to impersonate, but you have the permissions. There are additional audit functionalities which you get using the switching user / impersonate filter. In addition to all of that a user being logged in doesn't mean that there should be an authenticated session. There are other mechanisms that you can provide a consistent logging without using sessions. e.g. you can use a JWT token passed by the FE for each request or use some other form of token authentication.
Not sure why you are saying that the
Yes I can, but I do not expect a behaviour change from a patch release in Spring Security, especially not one as crucial as a session creation. I can argue the same thing about the reverse, if you want sessions then go ahead and make sure that the |
I am not understanding in what scenario you would need
If the |
It does work, we have our own mechanism. We provide our own The security context is created appropriately every time. I am not sure how it worked prior to 5.7. What I know is that prior to 5.7.7 the In my opinion the |
When upgrading to Spring Boot 2.7.11 and later we started having sessions even though we have explicitly configured the use of the
SecurityContextRepository
to be theNullSecurityContextRepository
. We traced this to #12834.From my analysis I can see that for #12504 a
SecurityContextRepository
was added to theSwitchUserFilter
with the default beingRequestAttributeSecurityContextRepository
. Although this is different than the other filters than use theNullSecurityContextRepository
as a default, it is still fine since it is not creating sessions. The other filters are:AbstractAuthenticationProcessingFilter
AuthenticationFilter
AbstractPreAuthenticatedProcessingFilter
RememberMeAuthenticationFilter
BasicAuthenticationFilter
DigestAuthenticationFilter
In my opinion the change done in #12834 is backwards incompatible change since all of a sudden sessions get created. I think that the default should be the same as the other filters i.e. use
NullSecurityContextRepository
and if a user wants to use something else they can set theSecurityContextRepository
that they want to use.e.g. We have our own
SwitchUserConfigurer
and we use:to apply the switch user. This means that people can get the configured security context repository and set it in their own configurer.
The text was updated successfully, but these errors were encountered: