From 3b78aa9493eca33301191401add548645c6f003f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 2 Dec 2014 11:18:23 +0000 Subject: [PATCH] Make Security auto-config conditional on spring-security-config SecurityAutoConfiguration, via its import of AuthenticationManagerConfiguration, requires spring-security-config to be on the classpath as AuthenticationManagerConfiguration extends GlobalAuthenticationConfigurerAdapter from spring-security-config. This commit makes SecurityAutoConfiguration conditional on the presence of GlobalAuthenticationConfigurerAdapter so that the auto-configuration will be disabled in its absence rather than causing an app to fail to start. Closes gh-2046 --- .../autoconfigure/security/SecurityAutoConfiguration.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java index c93b9271a4..aa462f3bf0 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.context.annotation.Import; import org.springframework.security.authentication.AuthenticationEventPublisher; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.DefaultAuthenticationEventPublisher; +import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; /** @@ -41,9 +42,11 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur * @Configuration of type {@link WebSecurityConfigurerAdapter}. * * @author Dave Syer + * @author Andy Wilkinson */ @Configuration -@ConditionalOnClass(AuthenticationManager.class) +@ConditionalOnClass({ AuthenticationManager.class, + GlobalAuthenticationConfigurerAdapter.class }) @EnableConfigurationProperties @Import({ SpringBootWebSecurityConfiguration.class, AuthenticationManagerConfiguration.class })