Is it possible to build Meta Annotations of Spring Security @PreAuthorize
like for @Component
or @Qualifier
?
What I want to do is replace @PreAuthorize("hasRole('ADMIN')")
by a shortcut like @IsAdmin
. But I did not find any hint in the documentation.
Yes, it's documented in the official documentation (Spring Security 5.1) : see Method Security Meta Annotations
Example provided :
@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("#contact.name == authentication.name")
public @interface ContactPermission {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With