I am in a situation were I need two login mechanisms for a single endpoint.
I have applied the suggestion from
Using multiple WebSecurityConfigurerAdapter in spring boot and have now ran into an issue wit the AuthenticationManager.
The AuthenticationManager lives in the WebSecurityConfigurerAdapter and is needed in the implementation of the ServiceWebSecurityConfigurer. However the ServiceWebSecurityConfigurer is used in the implementation of the WebSecurityConfigurerAdapter making a circular dependency.
@Configuration
@EnableWebSecurity
public class UnitedSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private List<ServiceWebSecurityConfigurer> serviceWebSecurityConfigurers;
@Override
public void configure(HttpSecurity http) {
serviceWebSecurityConfigurers.forEach(configurer -> configure.config(http));
}
@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
}
@Configuration
public class SecurityConfiguration implements ServiceWebSecurityConfigurer {
@Autowired
private AuthenticationManager authenticationManager;
@Bean
public SAMLWebSSOHoKProcessingFilter samlWebSSOHoKProcessingFilter() throws Exception {
SAMLWebSSOHoKProcessingFilter samlWebSSOHoKProcessingFilter = new SAMLWebSSOHoKProcessingFilter();
// AuthenticationManager needed here
samlWebSSOHoKProcessingFilter.setAuthenticationManager(authenticationManager);
return samlWebSSOHoKProcessingFilter;
}
}
How can I get out of this situation?