2017-02-09 68 views
0

我在Spring Security中使用了身份驗證提供程序。我有兩個身份驗證提供程序:LocalAuthenticationProviderRemoteAuthenticationProvider。認證流程是春季安全調用另一個身份驗證提供程序,即使第一個提供程序失敗

  1. 應用程序檢查在本地數據庫
  2. 如果是本地認證通過證書,需要調用RESTful Web服務進行身份驗證 憑證。
  3. 如果本地認證失敗,則認爲 認證失敗,響應401
@Override 
protected void configure(
    AuthenticationManagerBuilder auth) throws Exception { 
    auth.authenticationProvider(localProvider).authenticationProvider(remoteProvider); 
} 

LocalAuthenticationProvider拋出AuthenticationException如果憑據失敗。如果憑證是passed,則返回null

我的問題是Spring安全框架調用RemoteAuthenticationProvider甚至LocalAuthenticationProviderfailed

當我從AuthenticationManagerBuilder提供商列表中刪除RemoteAuthenticationProvider,它的作品甚至LocalAuthenticationProviderfailed

我想知道如何實現這個身份驗證流程。這兩個提供者是相互依賴的。

回答

相關問題