Sto*_*ica 7 spring spring-security spring-4
据我所知,注释或对象中只有任何列表可用。尝试添加多个注释或调用要么编译失败,要么只使用最新的。@Secured
ExpressionUrlAuthorizationConfigurer
hasAuthority()
如何定义特定请求(匹配模式的请求集)或方法需要所有角色/权限列表?
Sto*_*ica 11
最好的解决方案似乎是
@PreAuthorize("hasRole('one') and hasRole('two') and ...")
Run Code Online (Sandbox Code Playgroud)
没有像@Secured
.
您似乎正在使用:hasAuthority([authority])
。这只需要一个权限。而是使用hasAnyAuthority([authority1,authority2])
. 这允许您一次指定多个权限,并且任何一个都可以在授权中考虑。在这里参考官方 spring 文档。只需在页面中找到文本:hasAnyAuthority([authority1,authority2])
例如,在您的控制器方法中,添加:@PreAuthorize("hasAnyAuthority('permission1','permission2')")
归档时间: |
|
查看次数: |
9207 次 |
最近记录: |