我想限制登录尝试。因此,我创建了一个事件监听器:
@Component
public class AuthenticationFailureEventListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {
@Autowired
private LoginAttemptService loginAttemptService;
public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) {
WebAuthenticationDetails webAuthenticationDetails = (WebAuthenticationDetails) event.getAuthentication().getDetails();
loginAttemptService.loginFailed(webAuthenticationDetails.getRemoteAddress());
}
}
我正在将JHipster与JWT令牌一起使用