春季启动,hasAnyAuthority无法正常工作

时间:2020-04-25 15:29:11

标签: java spring-boot spring-security role-based-access-control

在我的configure(HttpSecurity)中,我有:

.antMatchers("/api/account/reset-password/finish").hasAnyAuthority(AuthoritiesConstants.BANK, AuthoritiesConstants.USER)

在这个特定端点中:

public void finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword)

我放在上面:

@PreAuthorize("hasAnyAuthority(\""+AuthoritiesConstants.BANK+"\", \""+AuthoritiesConstants.USER+"\")")

但是,当我使用邮递员与角色为“ ROLE_ADMIN”(未经授权)的管理员用户一起使用邮递员进行测试时,没有403,并且请求可以正常通过。

信息: AuthoritiesConstants.USER = "ROLE_USER"; AuthoritiesConstants.BANK = "ROLE_BANK"; AuthoritiesConstants.ADMIN = "ROLE_ADMIN";

0 个答案:

没有答案