spring-projects / spring-projects/spring-security
SEC-2726: Add a getStrategyName method to SecurityContextHolder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Magnus Hovén (Migrated from SEC-2726) said:
I have a client API that is used both by a desktop application and a web service. The strategy used by the SecurityContextHolder differs depending on if it is run as a web service (MODE_THREADLOCAL) or as a desktop application (MODE_GLOBAL). I have a case where a thread pool is used and for these threads I want to clear the context if it is a web service (for security reasons), but I can't do that for the desktop application since it would clear the context for all threads because of the global mode. In my case it would be very practical if I could call SecurityContextHolder.getStrategyName() to retrieve the strategy used and then I can choose to clear the context or not depending on what strategy that is used. Since the strategy is set in xml configuration file and since it also can be changed at run time, I think it would be much more cumbersome to try to retrieve the value in some other way.
So my suggestion is to add a getStrategyName method to SecurityContextHolder.
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.
Research direction
Start by locating SecurityContextHolder and reading how its strategy is configured and changed at runtime. Done means the class exposes getStrategyName so callers can retrieve the currently configured strategy name; check the existing SecurityContextHolder tests or test structure if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- security
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100