-
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
Spring issue 10032 causing User can't use own implementation of SecurityContext #11100
Comments
We tried to upgrade to Spring 5 and Spring Security 5 and we have encountered this issue as well. Our filter creates instance of our custom implementation of SecurityContext and it gets scrapped in AnonymousAuthenticationFilter, because user is not yet authenticated (Authentication is null). Line 94 in 9d37810
It seems like a wanted behavior according to: #8323 |
Thanks for the report, @chiqiu. Initially, this sounds like what With an instance of |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
I have not implemented my own SecurityContextHolderStrategy , do you mean that I should implement my own one and also assign a new filter so the [AnonymousAuthenticationFilter] will not be used? |
@chiqiu, you should be able to have your own |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
We ran into this very same issue when trying to migrate to Spring Security 5. For the last 10 years or so we have had our own Now then, when observing the calls to So, you are right @jzheaux that by implementing one's own However, if we look at ... Lines 49 to 55 in 9d37810
... it seems quite Wrong to me that a method that is described to be one that is
and
is now called again by the default filters after the initial call from Requesting this issue to be re-opened. |
@timo-eloranta Thanks for the detailed report.
It's not clear to me why you'd want There are three courses of action that I see:
I believe the first option to be the cleanest separation of the two concerns, but it also comes from a place of not knowing what exactly is happening in your code base and how the user and the additional context data interact. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
This doesn't work for me:
@jzheaux wasn't this your suggestion? I basically want something like this:
And have |
Describe the bug
in issue #10032
After authentication, a new SecurityContextImpl always replace user's own implementation of SecurityContext.
To Reproduce
Put a customized SecurityContext object before authentication. It will always be replaced by a SecurityContextImpl object after authentication
Expected behavior
User customized object isn't replaced
The text was updated successfully, but these errors were encountered: