|
26 | 26 | import org.springframework.core.Ordered;
|
27 | 27 | import org.springframework.core.annotation.Order;
|
28 | 28 | import org.springframework.core.log.LogMessage;
|
| 29 | +import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider; |
29 | 30 | import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
30 | 31 | import org.springframework.security.authentication.password.CompromisedPasswordChecker;
|
31 | 32 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
@@ -69,11 +70,18 @@ public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
69 | 70 | List<BeanWithName<UserDetailsService>> userDetailsServices = getBeansWithName(UserDetailsService.class);
|
70 | 71 | if (auth.isConfigured()) {
|
71 | 72 | if (!userDetailsServices.isEmpty()) {
|
72 |
| - this.logger.warn("Global AuthenticationManager configured with an AuthenticationProvider bean. " |
73 |
| - + "UserDetailsService beans will not be used for username/password login. " |
74 |
| - + "Consider removing the AuthenticationProvider bean. " |
75 |
| - + "Alternatively, consider using the UserDetailsService in a manually instantiated " |
76 |
| - + "DaoAuthenticationProvider."); |
| 73 | + List<BeanWithName<AbstractUserDetailsAuthenticationProvider>> userDetailsAuthenticationProviders = getBeansWithName( |
| 74 | + AbstractUserDetailsAuthenticationProvider.class); |
| 75 | + boolean wired = (userDetailsAuthenticationProviders.size() == userDetailsServices.size()); |
| 76 | + // we should check every UserDetailsService is actually wired |
| 77 | + // but getUserDetailsService() is not exposed |
| 78 | + if (!wired) { |
| 79 | + this.logger.warn("Global AuthenticationManager configured with an AuthenticationProvider bean. " |
| 80 | + + "UserDetailsService beans will not be used for username/password login. " |
| 81 | + + "Consider removing the AuthenticationProvider bean. " |
| 82 | + + "Alternatively, consider using the UserDetailsService in a manually instantiated " |
| 83 | + + "DaoAuthenticationProvider."); |
| 84 | + } |
77 | 85 | }
|
78 | 86 | return;
|
79 | 87 | }
|
|
0 commit comments