我在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
。
我想知道如何实现这个身份验证流程。这两个提供者是相互依赖的。