Skip to content

Calling SecurityContextHolder.setStrategyName(strategy) breaks Spring filters #13569

Description

@ChrisDelahunt

Calling SecurityContextHolder.setStrategyName(strategy) with any strategy name breaks spring filters because of code like:
https://github.com/spring-projects/spring-security/blob/c4485a8909119f88559dd4200cd3506024749529/web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.java#L118C7-L118C7

Many of our filters use SecurityContextHolder.getContext() directly, which will cause them to use a different strategy instance to look up the thread local context.

This makes changing the strategy difficult in situations where SecurityContextHolder.setStrategyName(strategy) cannot be called before Spring filters are initialized; the only solution is via system properties so that it is not reset in code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: bugA general bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions