Spring security access with multiple roles

后端 未结 3 1060
说谎
说谎 2021-02-02 14:49

I want to define access for some pages for user who has one of following roles (ROLE1 or ROLE2)

I\'m trying to configure this in my spring security xml file as following

相关标签:
3条回答
  • 2021-02-02 15:04

    If you are playing it with OAuth2, make sure you checkout this to solve your problems.

    http://lightweightyes.blogspot.in/2012/08/spring-security-expressions-not-working.html

    I just struggled hell lot of time trying all trial and errors.

    0 讨论(0)
  • 2021-02-02 15:05

    How try with , separate. See doc here and here.

    <security:intercept-url pattern="/rest/api/myUrl*" access="ROLE1,ROLE2"/>
    

    OR

    hasAnyRole('ROLE1','ROLE2')
    
    0 讨论(0)
  • 2021-02-02 15:15

    The problem was that I configured custom access-decision-manager-ref="accessDecisionManager" and didn't pass one of the voters.

    Solved by adding org.springframework.security.web.access.expression.WebExpressionVoter to accessDecisionManager bean.

    0 讨论(0)
提交回复
热议问题