检查多个角色是否具有方法级别访问权限
我已经使用@PreAuthorize注释来检查角色
@PreAuthorize("hasRole(\"" + AuthoritiesConstants.USER + "\",)" )
如何使用@PreAuthorize注解检查多个角色?
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER')")
hasAnyRole()
When you need to support multiple roles, you can use the hasAnyRole() expression.
@PreAuthorize("hasAnyRole('ADMIN','DB-ADMIN')")
https://docs.spring.io/spring-security/site/docs/3.0.x/reference/el-access.html https://docs.spring.io/spring-security/site/docs/3.0.x/reference/el-access.html
https://www.appsdeveloperblog.com/spring-security-preauthorize-annotation-example/ https://www.appsdeveloperblog.com/spring-security-preauthorize-annotation-example/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)