我正在尝试摆脱我们的securityContext.xml
,希望一次只声明一个……也升级到Spring Security 5,但仍然使用Oauth 2.2。
<security:authentication-manager
alias="authenticationManager">
<security:authentication-provider
user-service-ref="clientDetailsUserService" />
<security:authentication-provider
ref="dexAuthenticationProvider" />
</security:authentication-manager>
我尝试过
@Autowired
public void configureGlobal(
AuthenticationManagerBuilder builder,
DexAuthenticationProvider dexAuthenticationProvider,
ClientDetailsUserDetailsService clientDetailsUserDetailsService
) throws Exception {
builder.authenticationProvider( dexAuthenticationProvider )
.userDetailsService( clientDetailsUserDetailsService );
}
但是尝试创建此bean时出现错误
@Bean
ClientCredentialsTokenEndpointFilter clientCredentialsTokenEndpointFilter(
final AuthenticationManager authenticationManager ) {
ClientCredentialsTokenEndpointFilter endpointFilter = new ClientCredentialsTokenEndpointFilter();
endpointFilter.setAuthenticationManager( authenticationManager );
return endpointFilter;
}
这是个例外
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available: expected single matching bean but found 12: org.springframework.security.authentication.ProviderManager#0,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#1,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#1,org.springframework.security.authentication.ProviderManager#2,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#2,org.springframework.security.authentication.ProviderManager#3,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#3,org.springframework.security.authentication.ProviderManager#4,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#4,org.springframework.security.authentication.ProviderManager#5,authenticationManagerBean
嗯...这些全部是12个?应该只有1个?