Disable SecurityFilterAutoConfiguration when spring-security-web is missing

Previously, SecurityFilterAutoConfiguration would be created even if
spring-security-web was not on the classpath. This didn't cause a
failure as all of its beans were disabled. It was, however, wasteful,
as the configuration class was processed and a bean created for it
unnecessarily.

This commit makes the whole class conditional on the presence of
spring-security-web so that it will be skipped entirely when the
dependency is not available.

Closes gh-4160
This commit is contained in:
izeye 2015-10-13 19:19:57 +09:00 committed by Andy Wilkinson
parent 1e58f08b9a
commit 033823f493
1 changed files with 2 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.security;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.embedded.DelegatingFilterProxyRegistrationBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -41,6 +42,7 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn
@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties
@ConditionalOnClass(AbstractSecurityWebApplicationInitializer.class)
@AutoConfigureAfter(SpringBootWebSecurityConfiguration.class)
public class SecurityFilterAutoConfiguration {