Spring Meta Annotation Security Label

Is it possible to build Meta Annotatations of Spring Security @PreAuthorize for both @Component or @Qualifier ?

I want to replace @PreAuthorize("hasRole('ADMIN')") shortcut like @IsAdmin . But I did not find any hints in the documentation.

+11
java spring spring-security annotations
source share
2 answers

This works as a minimum with Spring Security 3.0.2.RELEASE:

 @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @PreAuthorize("hasRole('ADMIN')") public @interface IsAdmin { } 
+7
source share

The example esajs is correct:

 @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @PreAuthorize("hasRole('ADMIN')") public @interface IsAdmin { } 

however, for some strange undocumented reason, this will not work in my Spring Boot project (vr 2.1.2.RELEASE) without proxyTargetClass in the proxyTargetClass parameter proxyTargetClass for example:

 @EnableGlobalMethodSecurity( prePostEnabled = true, proxyTargetClass = true ) 
0
source share

All Articles