我在Spring Security中使用了身份驗證提供程序。我有兩個身份驗證提供程序:LocalAuthenticationProvider
和RemoteAuthenticationProvider
。認證流程是春季安全調用另一個身份驗證提供程序,即使第一個提供程序失敗
- 應用程序檢查在本地數據庫
- 如果是本地認證通過證書,需要調用
RESTful
Web服務進行身份驗證 憑證。 - 如果本地認證失敗,則認爲 認證失敗,響應
401
。
@Override protected void configure( AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(localProvider).authenticationProvider(remoteProvider); }
LocalAuthenticationProvider
拋出AuthenticationException
如果憑據失敗。如果憑證是passed
,則返回null
。
我的問題是Spring安全框架調用RemoteAuthenticationProvider
甚至LocalAuthenticationProvider
是failed
。
當我從AuthenticationManagerBuilder
提供商列表中刪除RemoteAuthenticationProvider
,它的作品甚至LocalAuthenticationProvider
是failed
。
我想知道如何實現這個身份驗證流程。這兩個提供者是相互依賴的。