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
pull/2707/head
Andy Wilkinson 10 years ago
parent 41c15f205f
commit 3b78aa9493

@ -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
* <code>@Configuration</code> 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 })

Loading…
Cancel
Save