-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add API for Looking Up Security Annotations #15700
Comments
Hi, @mauromol, thanks for the suggestion. Spring Security 6.4 adds The basic usage is: SecurityAnnotationScanner<AnAnnotation> scanner = SecurityAnnotationScanners.requireUnique(AnAnnotation.class);
// ...
AnAnnotation annotation = scanner.scan(method, targetClass); Are you able to try out |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
I backported the Thanks a lot! |
Closed in 626610a |
Expected Behavior
AuthorizationAnnotationUtils
may be very useful if you plan to implement your own security annotation and corresponding authorization manager, because it adds additional security behaviour to the classicAnnotationUtils
in Spring Framework.Hence, it would be useful if custom extensions could use it.
Current Behavior
AuthorizationAnnotationUtils
is package-private, so can't be used by custom implementations. You either need to copy its code (running the risk to lose fixes in newer versions of Spring Security) or to just useAnnotationUtils
(running the risk to process duplicate contradictory annotations in an unsafe way).Context
I needed to create a custom annotation very similar to
Secured
, which however works with our role enumeration instead of with plain strings. So I created anAdvisor
for it as described at https://docs.spring.io/spring-security/reference/5.8/servlet/authorization/method-security.html#jc-method-security-custom-authorization-manager, but I also needed to write a properAuthorizationManager
to extract my annotation value from the target method/class and use it to computeAuthorizationDecision
s.Working with Spring Security 5.8.13.
The text was updated successfully, but these errors were encountered: