クライアント認証の成功やユーザー認証の成功/失敗など、いくつかのイベントを Event Publisher に発行できます。ただし、クライアントの資格情報が間違っている場合、イベントは発行されません。
ログは次のとおりです。
DEBUG::org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter::doFilter::Request is to process authentication
DEBUG::...ClientCredentialsTokenEndpointFilter::unsuccessfulAuthentication::Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
DEBUG::...ClientCredentialsTokenEndpointFilter::unsuccessfulAuthentication::Updated SecurityContextHolder to contain null Authentication
DEBUG::...ClientCredentialsTokenEndpointFilter::unsuccessfulAuthentication::Delegating to authentication failure handler org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter$1@734b2ca6
DEBUG::org.springframework.security.oauth2.provider.error.DefaultOAuth2ExceptionRenderer::writeWithMessageConverters::Written [error="invalid_client", error_description="Bad client credentials"] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@37536106]
spring-security-oauth2 の2.0.8-RELEASEでは、(AuthorizationServerConfigurerAdapter を介して) ClientCredentialsTokenEndpointFilter にカスタムの失敗ハンドラーを設定する方法がないようです。
また、インターセプターを追加してもうまくいかないようです。
それとも私のやり方が間違っているのでしょうか...
Spring Boot+OAuth2 ですべての認証イベントをキャッチできた人はいますか?