Skip to content

SEC-1993: Provide explicit method to remove SecurityContext for custom SecurityContextRepository's #2218

Closed
@spring-projects-issues

Description

@spring-projects-issues

Jonathan Baker (Migrated from SEC-1993) said:

Updated Description

My problem is that there is an abstraction called SecurityContextRepository (currently the primary implementation stores the security context in the session)
When you call clear context, that removes the security context from the holder, but not from the security context repository. By invalidating the session you are essentially clearing the security context from the security context repository via a backdoor. It would be better if you explicitly removed the security context from the security repository via a method on the SecurityContextRepository interface. This is because not everyone stores their security context in the http session. Some people have implemented their own security context repository. For people with a non-session-based SecurityContext repository invalidating the session does nothing, and we have to code some hack to actually get the security context cleared out.
It may be that you still need to invalidate the http session but you should add an explicit call to clear the security context repository first.

h1. Original Description

One of the nice features of spring security is that it has an abstraction for SecurityContextRepository. The default implementation is in the HttpSession, but it was nice that there was a layer there in case people wanted to use some other persistence mechanism for the security context. We are one of the people who created a service to store the security context so it can be shared across servers.

However the SecurityContextLogoutHandler accesses the http session to invalidate it directly. It would be nice if this class removed the security context from the security context repository instead of (or in addition to) invalidating the session.

This could be driven by a boolean property as well cleanContextFromContextRepository or something like that...

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementtype: jiraAn issue that was migrated from JIRA

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions