spring-projects / spring-projects/spring-security
Annotation for Automatic Detection of Authenticated Routes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Expected Behavior
The functionality should work based on an annotation applied to Controllers. Let's assume we'll call it @Authenticated. Once this annotation is present on a method, we can use the application context to retrieve all routes and check if they have this annotation.
If the annotation is present, we can use an AntPathMatcher to match the path and method, and subsequently add it to the SecurityConfig.
Current Behavior
Currently, the developer must manually create a list of routes they want to authenticate. With the annotation, we propose a different approach to automate this process.
Context
This issue has added complexity to the development process, as developers need to manually manage and update the list of authenticated routes. The goal is to simplify and automate this process by introducing an annotation-based approach.
Alternatives considered include:
Manually maintaining the list of authenticated routes (current approach).
Using reflection to scan for specific method signatures or patterns.
Implementing a custom route registration mechanism.
A potential workaround is to use reflection to dynamically detect methods that require authentication, but this can be error-prone and less maintainable compared to an annotation-based solution.
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 tracing how Controllers, the application context, AntPathMatcher, and SecurityConfig currently represent and authenticate routes. Define how an @Authenticated method is discovered and mapped to its path and HTTP method. Done means annotated routes are added to authentication requirements without a manually maintained route list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100