具有多个角色的弹簧安全访问
2022-09-02 08:57:44
我想为具有以下角色之一(ROLE1 或 ROLE2)的用户定义某些页面的访问权限
我正在尝试在我的spring安全xml文件中配置它,如下所示:
<security:http entry-point-ref="restAuthenticationEntryPoint" access-decision-manager-ref="accessDecisionManager" xmlns="http://www.springframework.org/schema/security" use-expressions="true">
<!-- skipped configuration -->
<security:intercept-url pattern="/rest/api/myUrl*" access="hasRole('ROLE1') or hasRole('ROLE2')" />
<!-- skipped configuration -->
</security:http>
我尝试了各种方法,例如:
access="hasRole('ROLE1, ROLE2')"
access="hasRole('ROLE1', 'ROLE2')"
access="hasAnyRole('[ROLE1', 'ROLE2]')"
等
但似乎没有任何效果。
我一直有异常
java.lang.IllegalArgumentException: Unsupported configuration attributes:
或
java.lang.IllegalArgumentException: Failed to parse expression 'hasAnyRole(['ROLE1', 'ROLE2'])'
应该如何配置?
谢谢