-
Notifications
You must be signed in to change notification settings - Fork 6k
SEC-1082: SecurityContextHolderAwareRequestWrapper do not expose anonymous user. #1333
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
Comments
Luke Taylor said: Please can you explain the requirement here? If you can give a detailed example of what you’re trying to do and explain why it’s not currently possible, that would be very useful. |
Marcin Muras said: Hi. Please look at SecurityContextHolderAwareRequestWrapper.getAuthentication(): Whats more in Spring Webflow we can get logged user in EL by invoking “currentUser” expression. I wrote CustomSavedRequestAwareWrapper to expose also anonymous user. (see attachement) |
Luke Taylor said: I’m still not clear what the requirement is. This wrapper is intended to mimic the servlet API and, as I’ve explained in other issues, there is no concept of an “anonymously authenticated” user in standard servlet security. The standard servlet methods should therefore return null if nobody is authenticated. |
Marcin Muras said: Yes exactly this wrapper mimic servlet API. And Spring Webflow use Servlet API to access logged user as “currentUser”. So webflow never access anonymous user. |
Luke Taylor said: I still don't see why there would be an expectation that accessing the "currentUser" in webflow when there is nobody authenticated should return something other than null. If it is being used without Spring Security (with normal container authentication) then the servlet API would return null. Likewise if Spring Security is being used without an AnonymousProcessingFilter. An application based on the servlet API shouldn't be assuming that Spring Security is in use. |
Marcin Muras said: Yes all what you said is true. But lets talk about case when you use Servlet API with Spring Security AND AnonymousProcessingFilter. Summary: It think that the question here is: |
Luke Taylor said: The point of the servlet API is that it is independent of Spring Security and has standard documented behaviour. Existing applications may depend on that behaviour so we are unlikely to change it. If an application knows that it is using Spring Security, then it can use Spring Security APIs to access the security context. The use of an AnonymousProcessingFilter does not mean that "someone was authenticated" from Spring Security's point of view. Any unauthenticated access will be represented by an anonymous token in the security context. The reason this was originally introduced was to simplify the configuration of access controls in the security application context. If you read the chapter in the reference manual it explains this. |
marcin muras(Migrated from SEC-1082) said:
SecurityContextHolderAwareRequestWrapper do not expose Authentication if user was anonymous (see getAuthentication() method).
It is fine but for example while using with webflow it is not so good. Webflow expose request principal (request.getPrincipal()) as “currentUser”. It means we will never have currentUser set if it was anonymous.
It may be good to add some property to SecurityContextHolderAwareRequestWrapper class to tell that we want to expose anonymous user.
The text was updated successfully, but these errors were encountered: