以我的名义,我有两个角色["ADMIN", "BLOCKED"]
。我想拒绝访问资源("/order")
的这组角色,并允许访问,如果令牌仅包含一个角色["ADMIN"]
我正在尝试这样的事情:
.antMatchers("/home", "/cart") // allow access to this resources if token contains two roles ["ADMIN", "BLOCKED"]
.hasAnyAuthority("BLOCKED", "ADMIN")
.antMatchers("/order")//allow access only if token contain one role ["ADMIN"]
.hasAuthority("ADMIN")
但是在此安全配置中,如果令牌包含两个角色["ADMIN", "BLOCKED"]
,则不会拒绝对/order
的许可。如何解决?