spring-projects / spring-projects/spring-security
Consider warning users if securityMatchers do not match some filter in the chain
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Describe the bug
HttpSecurity configuration with securityMatcher and oauth2Login(withDefaults()) leads to 404 for some OAuth2 endpoints.
To Reproduce
- Clone this repo: https://github.com/Haarolean/spring-security-matchers-bug
- Run the app
- Go to
http://localhost:8080/oauth2/authorization/github - Observe 404
Also,
- Commenting line 25 in
OAuthSecurityConfigfixes the issue. - Endpoint like
http://localhost:1337/login/oauth2/code/github?code=xxxstill works for some reason. - I've traced the issue down to
MvcRequestMatcher, wherenotMatchMethodOrServletPathalways results intrue. Without line 25,MvcRequestMatcheris not used, ratherAnyRequestMatcheris being used. - I've dug through all the possible documentation on
securityMatcherand didn't find anything which could explain the problem.
Expected behavior
oauth, csrf, cors and other configurations are applied only for /api/web/**.
Sample
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 the linked reproduction, run the app, and inspect line 25 of OAuthSecurityConfig. Trace how MvcRequestMatcher and AnyRequestMatcher affect the filter chain for /oauth2/authorization/github and the callback endpoint. Done means the configuration behavior is explained and the proposed warning or related handling is covered by appropriate project tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100