私のアプリは、Spring Cloud oauth2 rest と angular を使用しています。
私の目標は、春のサーバーを使用して、ログイン失敗の最大数を制限することです
angular2 ログイン コード:
const body = "username=" + encodeURI(username) + "&password=" + encodeURI(password) +
"&grant_type=password&client_id=" + encodeURI(this.clientId);
this.http.post("/oauth/token",body,{headers:authHeaders}).map{
...
}
春の認証サーバー Web セキュリティ コード:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().authorizeRequests()
.anyRequest().authenticated();
}
私はこれらの2つのイベントを試します:
public class AuthenticationFailureListener
implements ApplicationListener<AuthenticationFailureBadCredentialsEvent>{
@Override
public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent e) {
//...
}
}
と:
public class AuthenticationSuccessListener
implements ApplicationListener<AuthenticationSuccessEvent> {
@Override
public void onApplicationEvent(AuthenticationSuccessEvent e) {
//...
}
}
しかし、それは機能しません
「ログイン失敗と成功」を聞く方法は?