Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security Meta Annotation

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.

like image 435
Ralph Avatar asked Mar 23 '11 08:03

Ralph


1 Answers

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 {}
like image 92
Guillaume Husta Avatar answered Sep 18 '22 17:09

Guillaume Husta