Spring Boot + Spring Security + Hierarchical Roles

前端 未结 5 1810
甜味超标
甜味超标 2020-12-13 21:59

I\'m trying to setup hierarchical roles in my Spring Boot app without success. I\'ve done all that\'s been said in different places in the Internet. But with none of them ha

5条回答
  •  失恋的感觉
    2020-12-13 22:28

    You need to set the role hierarchy on the web expression voter. Something like:

    DefaultWebSecurityExpressionHandler expressionHandler = new DefaultWebSecurityExpressionHandler();
    expressionHandler.setRoleHierarchy(roleHierarchy);
    webExpressionVoter.setExpressionHandler(expressionHandler);
    

    Update: You could also try setting the the above expression handler like this:

    http
        .authorizeRequests()
        .expressionHandler(expressionHandler)
        ...
    

提交回复
热议问题