-
Notifications
You must be signed in to change notification settings - Fork 6k
SecurityFilterChain picks up wrong Authentication Provider #11601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could be related #10005 |
@pavankjadda, when I copy the beans into my IDE, they don't compile due to referring to several other components in your application. Will you please post a minimal sample? The best way is to share a GitHub repo that has only the necessary components to reproduce the issue. |
I created new repository that reproduces the issue. Make sure replace the AD config based on your environment. |
Sorry for the delay on this ticket, @pavankjadda. I believe this is because What I'd recommend instead is to formulate two @Bean
public SecurityFilterChain externalFilterChain(HttpSecurity http,
ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider) throws Exception {
ProviderManager manager = new ProviderManager(activeDirectoryLdapAuthenticationProvider);
return http.antMatcher("/api/v1/external/search/**")
.httpBasic(basic -> {})
.authorizeRequests(authorize -> authorize.anyRequest().authenticated())
.authenticationManager(manager)
.build();
}
@Bean
public SecurityFilterChain defaultFilterChain(HttpSecurity http,
ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider,
DaoAuthenticationProvider daoAuthenticationProvider) throws Exception {
ProviderManager manager = new ProviderManager(
activeDirectoryLdapAuthenticationProvider, daoAuthenticationProvider);
return http
.httpBasic(basic -> {})
.authorizeRequests(authorize -> authorize.anyRequest().authenticated())
.authenticationManager(manager)
.build();
} Because there is only one component for the DSL to decide on in this case, the precedence rules are a bit easier to manage with this arrangement. |
Describe the bug
In my project we have 2 SecurityFilterChains
externalFilterChain
for external API requestsdefaultlFilterChain
for Angular/React client applicationsWe use LDAP and JDBC authentication. Both
activeDirectoryLdapAuthenticationProvider
anddaoAuthenticationProvider
injected as beans. But externalFilterChain picks updaoAuthenticationProvider
even though I specifically said it to useactiveDirectoryLdapAuthenticationProvider
To Reproduce
External API FilterChain:
Default FilterChain:
AuthenticationProvider Beans:
Expected behavior
User should be authenticated with provided Authentication Provider
Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.
The text was updated successfully, but these errors were encountered: