AuthenticationFailureBadCredentialsEvent永远没有被调用
创始人
2024-09-22 14:30:36
0

在代码中添加监听器,以便在身份验证失败时调用AuthenticationFailureBadCredentialsEvent事件。以下是示例代码:

@Component public class AuthenticationFailureListener extends AbstractAuthenticationFailureEvent {

@Autowired
private ApplicationEventPublisher eventPublisher;

@Override
public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
    eventPublisher.publishEvent(event);
}

}

在您的配置中添加以下代码:

@Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private AuthenticationFailureListener authenticationFailureListener;

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .addFilterBefore(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
        .exceptionHandling()
        .authenticationEntryPoint(authenticationEntryPoint())
        .and()
        .authorizeRequests()
        .antMatchers("/public/**").permitAll()
        .anyRequest().authenticated()
        .and()
        .csrf().disable()
        .formLogin()
        .loginProcessingUrl("/authenticate")
        .successHandler(authenticationSuccessHandler())
        .failureHandler(authenticationFailureHandler())
        .and()
        .logout()
        .logoutUrl("/logout")
        .logoutSuccessHandler(logoutSuccessHandler());
}

@EventListener
public void onAuthenticationFailure(AuthenticationFailureBadCredentialsEvent event) {
    authenticationFailureListener.onApplicationEvent(event);
}

}

相关内容

热门资讯

为切实保障!wepoker透视... 为切实保障!wepoker透视有吗,pokerrrr2辅助,方针教程(有挂技术)-哔哩哔哩1、起透看...
为了进一步!hhpoker怎么... 为了进一步!hhpoker怎么破解(透视)原来是有挂(有挂方针开挂辅助下载)-哔哩哔哩1、完成hhp...
近日!智星菠萝透视,智星菠萝透... 近日!智星菠萝透视,智星菠萝透视,模板教程(有挂透明挂)-哔哩哔哩1、全新机制【智星菠萝透视软件透明...
截至目前!wepoker免费脚... 截至目前!wepoker免费脚本咨询(透视)原来有挂(有挂秘笈开挂辅助平台)-哔哩哔哩1、任何wep...
有了最新消息!xpoker辅助... 有了最新消息!xpoker辅助神器,wepoker怎么发冤家牌,策略教程(有挂教程)-哔哩哔哩1、在...
据通报!wpk模拟器(透视)其... 据通报!wpk模拟器(透视)其实是有挂(有挂分享开挂辅助插件)-哔哩哔哩wpk模拟器辅助器中分为三种...
长期以来!拱趴大菠萝万能挂图解... 长期以来!拱趴大菠萝万能挂图解,steampokermaster辅助,方针教程(有挂规律)-哔哩哔哩...
昨日!德普之星透视免费(透视)... 昨日!德普之星透视免费(透视)果然是有挂的(有挂详情开挂辅助辅助器)-哔哩哔哩一、德普之星透视免费A...
备受关注的!哈糖大菠萝助手,p... 备受关注的!哈糖大菠萝助手,pokemmo辅助工具,课程教程(有挂详细)-哔哩哔哩1、任何哈糖大菠萝...
围绕透视问题!aapoker透... 围绕透视问题!aapoker透视脚本入口(透视)一贯确实有挂(有挂方式开挂辅助下载)-哔哩哔哩所有人...