Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation for Automatic Detection of Authenticated Routes #16563

Open
imerik1 opened this issue Feb 10, 2025 · 0 comments
Open

Annotation for Automatic Detection of Authenticated Routes #16563

imerik1 opened this issue Feb 10, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement

Comments

@imerik1
Copy link

imerik1 commented Feb 10, 2025

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.

@imerik1 imerik1 added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant