spring-projects / spring-projects/spring-security
Use SecurityContextHolderStrategy
@jzheaux is already working on this.
Since Jun 21, 2022.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
When components access the SecurityContext statically through SecurityContextHolder, this can create race conditions when there are multiple application contexts that want to specify the SecurityContextHolderStrategy. This is because in SecurityContextHolder there is one strategy per classloader instead of one per application context.
To address this, components could wire SecurityContextHolderStrategy from the application context. By default, they will still look up the strategy from SecurityContextHolder. Additionally, though, there will be the option to set the SecurityContextHolderStrategy on components that work with the SecurityContext.
One of the nice consequences of this is that applications will be able to publish a SecurityContextHolderStrategy bean in their application context, and the security filters and other components will use the custom one instead.
These changes are largely internal, though note that they present the opportunity for applications to autowire the SecurityContextHolderStrategy instead of accessing the SecurityContext statically.
- #11059
- #11060
- #11061
- #11444
- #11886
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.