-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow multiple security annotations on a method (combining result of evaluations with AND operator) #4003
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
Comments
I think it's a good feature request. Has anyone considered this request? |
It would be great, there would be no need to create role combined annotations like @IsAdminAndUSer |
Anyone interested in putting together a pull request? |
Hi @rwinch, may I? |
@parikshitdutta Thank you for volunteering. The issue is yours |
Closing in favor of #9630 |
When using Spring Security's annotations are not repeatable, so you can't have two instances of |
@jzheaux but this is not what we request, we want to repeat PreAuthorize annotation and not combine multiple annotation types use case - you have multiple rules and some endpoints are related to some of them so instead of creating 5 annotations for 5 rules and repeat them we have to create many custom annotations with any possible combination we need, there could be some new annotation to group PreAuthorize something like PreAuthorizeAll(PreAuthorize[]) and PreAuthorizeAny(PreAuthorize[]) or just allow repeat them with AND operator |
Summary
Allow multiple security annotations on a single method
Actual Behavior
Currently if there are multiple annotations (PreAuthorize or Secured) on a single method only one is actually used.
Proposed Behavior
Each annotation is evaluated with an AND condition connecting them all.
Rationale
This will work very well with meta annotations. Currently, complex security restrictions require code duplication. Instead, I could define a few common security constraints in their own meta annotations and compose my security requirements by placing the appropriate annotations on the method.
Version
Sample Proposed Behaviour
The text was updated successfully, but these errors were encountered: