Spring Security——认证失败时获取认证信息

2021-07-20  本文已影响0人  CoderZS
@Component
public class AuthenticationFailureListener implements ApplicationListener<AbstractAuthenticationFailureEvent> {
  @Override
  public void onApplicationEvent(AbstractAuthenticationFailureEvent event) {
    //登陆账号 密码
    Object username = event.getAuthentication().getPrincipal();
    Object credentials = event.getAuthentication().getCredentials();
    Object details=event.getAuthentication().getDetails();
    String ip = ((WebAuthenticationDetails)details).getRemoteAddress();
  }
}
图片.png
上一篇 下一篇

猜你喜欢

热点阅读