spring-projects / spring-projects/spring-security
Provide a way to customize the default RequestCache without replacing the entire implementation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Spring Security 6.2.5
Without any customization, the default RequestCache is HttpSessionRequestCache (created by private methods in RequestCacheConfigurer). For some situations, it would be necessary to customize that cache. An example I have run into is needing to extend the cache's RequestMatcher to exclude certain requests from being cached (see this SO question for specifics).
As far as I can see, the only customization option for a typical SecurityFilterChain bean is to completely replace the RequestCache object via RequestCacheConfigurer<HttpSecurity>.requestCache(). That's far from ideal as many applications will want the default configured cache with only minor changes. Since the configurer's methods that create or use the default are all private, that's not currently possible.
It would be useful for RequestCacheConfigurer to expose a way to get to the default cache, so the application can customize it. Even if it required a cast, that would likely be a "lesser of 2 evils" choice for many developers.
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 with RequestCacheConfigurer and its private methods that create or use the default HttpSessionRequestCache, then review how SecurityFilterChain configuration reaches requestCache(). Determine an API that permits customizing the default cache without replacing it, and verify that existing default behavior remains unchanged while applications can adjust the cache's RequestMatcher.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100