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 )
Adam from WALCZAK.IT
source share