LoginSignup
1
0

More than 5 years have passed since last update.

spring securityで自前のAuthenticationProviderが二回呼ばれて認証失敗する

Last updated at Posted at 2018-05-16

現象

タイトル通り。

一回目のAuthenticationProvider呼び出しでUsernamePasswordAuthenticationTokenを返して認証OKとしても、もう一度AuthenticationProviderが呼ばれて認証失敗となる。二回目の呼び出しではCredentialsがnullになるので認証失敗に終わる。

原因と解決策

java - spring security custom AuthenticationProvider is called twice and fails - Stack Overflow

UsernamePasswordAuthenticationTokenのコンストラクタに引数が3つあるやつを使用する。これを使うとisAuthenticated()がtrueを返すようになる。これで二回呼ばれなくなる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0