Multiple roles using @PreAuthorize

后端 未结 3 1724
长发绾君心
长发绾君心 2021-01-13 13:37

To check multiple roles has the method level access

I have used @PreAuthorize annotation to check the role

@PreAuthorize(\"hasRole(\\\"\" + AuthoritiesCons

3条回答
  •  遥遥无期
    2021-01-13 13:55

    Simply combine roles by using && or || in SpEL expressions

    @PreAuthorize("hasRole('" + AuthoritiesConstants.USER + "')" +
                  " && hasRole('" + AuthoritiesConstants.ADMIN + "')" )
    

提交回复
热议问题