AuthenticationVoters属性无效。SpringSecurity
创始人
2024-09-22 14:31:15
0

在Spring Security中,AuthenticationVoters属性用于配置投票器,用于决定是否允许特定的身份验证令牌。如果出现“AuthenticationVoters属性无效”的错误消息,可能是由于以下原因之一:

  1. 类型错误:检查AuthenticationVoters属性的值是否正确。它应该是一个List类型的对象。确保在属性中提供的值是一个有效的AuthenticationVoter列表。

示例代码:

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .and()
                .httpBasic();
    }

    @Bean
    public AuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(userDetailsService());
        authenticationProvider.setPasswordEncoder(passwordEncoder());
        return authenticationProvider;
    }

    @Bean
    public UserDetailsService userDetailsService() {
        // return your custom UserDetailsService implementation
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        // return your preferred PasswordEncoder implementation
    }

    @Bean
    public List> authenticationVoters() {
        List> authenticationVoters = new ArrayList<>();
        authenticationVoters.add(new RoleVoter());
        authenticationVoters.add(new AuthenticatedVoter());
        return authenticationVoters;
    }
}

在上面的示例中,我们使用authenticationVoters()方法返回一个包含两个投票器的列表:RoleVoterAuthenticatedVoter

  1. 配置错误:检查是否存在其他配置错误,可能导致无效的AuthenticationVoters属性。确保在配置中没有其他错误,并且所有其他属性都正确设置。

请根据您的具体情况检查和调整代码,确保AuthenticationVoters属性配置正确无误。

相关内容

热门资讯

2026版总结!hhpoker... 2026版总结!hhpoker脚本下载,德普之星辅助工具如何打开,切实真的是有挂(有挂教程)1、该软...
推出新举措!悦扑克脚本,德普之... 推出新举措!悦扑克脚本,德普之星透视辅助,果然确实有挂(有挂秘诀)亲,关键说明,德普之星透视辅助透视...
今天上午!wepoker辅助器... 今天上午!wepoker辅助器软件下载,德普之星私人局透视,都是是有挂(有挂实锤)1)德普之星私人局...
攻略辅助挂!wpk有辅助器吗,... 攻略辅助挂!wpk有辅助器吗,德普之星透视辅助软件是真的吗,本来存在有挂(新版有挂)亲,关键说明,德...
据目击者称!xpoker辅助助... 据目击者称!xpoker辅助助手,德普之星透视辅助软件下载,一直真的有挂(有挂详情)进入游戏-大厅左...
刚刚!智星菠萝透视,智星德州辅... 刚刚!智星菠萝透视,智星德州辅助译码插件靠谱吗,好像是有挂(的确有挂)进入游戏-大厅左侧-新手福利-...
教学辅助挂!wepokerh5... 教学辅助挂!wepokerh5破解,德普之星app安卓版破解版,都是确实有挂(有挂详情)1、许多玩家...
此事引发网友热议!pokemm... 此事引发网友热议!pokemmo手机版脚本,德普之星透视辅助插件,总是确实有挂(有挂方针)1、完成德...
针对!wepoker怎么挂飞机... 针对!wepoker怎么挂飞机,德扑之星私人局透视,好像是有挂(有挂教学)1、下载好德扑之星私人局透...
据权威媒体报道!aapoker... 据权威媒体报道!aapoker发牌逻辑,德普之星有透视辅助吗,总是真的有挂(详细教程)1、德普之星有...