首页 > 解决方案 > AuthenticationVoters 没有有效的属性。SpringSecurity

问题描述

我在 Spring Boot 2.1 上工作。

我希望允许我的所有默认端点

我的代码:

安全配置.java

protected void configure(HttpSecurity http) throws Exception {
  http.csrf()
    .disable().cors().and().exceptionHandling()
    /* [...] */
  .anyRequest()
    .authenticated();
    .accessDecisionManager(playerResourceDecisionManager());
}
@Bean
public AccessDecisionManager playerResourceDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters = Arrays.asList(
        new AuthenticatedVoter(),
        hashSerialSecurityVoter
    );
    return new UnanimousBased(decisionVoters);
}

它有效地通过两个选民。
但是在 AuthenticatedVoter 中,它并没有按我预期的那样运行。

即使我通过了身份验证,它也会返回ACCESS_ABSTAIN 值。

当我调试它时,我注意到 Manager 没有提供任何 ConfigAttribute。
所以authenticatedVoter.supports()方法返回false..

我错过了 accessDecisionManager 声明中的某些内容吗?

结果是我的主要 API 客户端不再工作,因为我的所有请求都返回 403。

标签: javaspringspring-bootspring-security

解决方案


推荐阅读