Security Annotations
Everything @PreAuthorize, @RolesAllowedand @Securedare annotations that allow you to configure the security of the method. They can be applied both to individual methods and at the class level; in the latter case, security restrictions will apply to all methods in the class.
Spring AOP.
@PreAuthorize
@PreAuthorize , Spring (SpEL). , , . @PreAuthorize Spring Security.
@PreAuthorize, prePostEnabled
@EnableGlobalMethodSecurity true:
@EnableGlobalMethodSecurity(prePostEnabled=true)
@RolesAllowed
@RolesAllowed Java JSR-250.
, @PreAuthorize, .
@RolesAllowed, , , , Spring Security. , jsr250Enabled @EnableGlobalMethodSecurity true:
@EnableGlobalMethodSecurity(jsr250Enabled=true)
@Secured
@Secured - Spring Security 2, . , Spring Expression Language (SpEL) . @PreAuthorize .
@Secured
@EnableGlobalMethodSecurity securedEnabled:
@EnableGlobalMethodSecurity(securedEnabled=true)
SpEL
Spring Expression Language , Spring Security 5:
βββββββββββββββββββββββ¦ββββββββββββββββββββ
β Security Annotation β Has SpEL Support? β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @PreAuthorize β yes β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @PostAuthorize β yes β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @PreFilter β yes β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @PostFilter β yes β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @Secured β no β
β ββββββββββββββββββββββ¬ββββββββββββββββββββ£
β @RolesAllowed β no β
βββββββββββββββββββββββ©ββββββββββββββββββββ