SAML与带DB登录的spring boot集成(多个WebSecurity配置适配器)
我正在将SAML2与已经使用数据库与CustomAuthenticationProvider进行登录的现有应用程序集成。当我添加SAML登录时,应用程序的数据库登录不起作用。在我看来,SAML与带DB登录的spring boot集成(多个WebSecurity配置适配器),spring,spring-security,saml-2.0,spring-saml,Spring,Spring Security,Saml 2.0,Spring Saml,我正在将SAML2与已经使用数据库与CustomAuthenticationProvider进行登录的现有应用程序集成。当我添加SAML登录时,应用程序的数据库登录不起作用。在我看来,.antMatchers(“/api/authenticate”).permitAll()不起作用。如果删除SAML配置,则DB登录可以正常工作。 以下是配置: 在上述配置中,只有SAML登录有效,而不是DB登录 I solved it by using the following configuration. I
.antMatchers(“/api/authenticate”).permitAll()
不起作用。如果删除SAML配置,则DB登录可以正常工作。
以下是配置:
在上述配置中,只有SAML登录有效,而不是DB登录
I solved it by using the following configuration. I created separate WebSecurityConfigurerAdapter for application login and SAML login.
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
@Import(SecurityProblemSupport.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {}
关键是添加@Autowired for configure()和添加@Order()。我不知道它为什么起作用,但下面的配置就起作用了
@EnableWebSecurity
@Configuration
@Order(1)
public class SamlAuthConfig extends WebSecurityConfigurerAdapter {
@Autowired
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(customAuthenticationProvider).authenticationProvider(samlAuthenticationProvider());
}
}
这帮助我解决了这个问题。是否同时添加了两个身份验证提供程序,例如:
auth.authenticationProvider(samlAuthenticationProvider()).authenticationProvider(customAuthenticationProvider)代码>?@Ritesh否,我将它们添加到各自的配置中。