Make security auto-configs back off when SecurityFilterChain present
Closes gh-22739
This commit is contained in:
@@ -52,7 +52,8 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl
|
||||
private static final Class<?>[] NO_CONTROLLERS = {};
|
||||
|
||||
private static final String[] OPTIONAL_INCLUDES = {
|
||||
"org.springframework.security.config.annotation.web.WebSecurityConfigurer" };
|
||||
"org.springframework.security.config.annotation.web.WebSecurityConfigurer",
|
||||
"org.springframework.security.web.SecurityFilterChain" };
|
||||
|
||||
private static final Set<Class<?>> DEFAULT_INCLUDES;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -57,6 +58,7 @@ class WebMvcTypeExcludeFilterTests {
|
||||
assertThat(excludes(filter, ExampleService.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
|
||||
assertThat(excludes(filter, SecurityFilterChain.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleModule.class)).isFalse();
|
||||
}
|
||||
@@ -72,6 +74,7 @@ class WebMvcTypeExcludeFilterTests {
|
||||
assertThat(excludes(filter, ExampleService.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
|
||||
assertThat(excludes(filter, SecurityFilterChain.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleModule.class)).isFalse();
|
||||
}
|
||||
@@ -87,6 +90,7 @@ class WebMvcTypeExcludeFilterTests {
|
||||
assertThat(excludes(filter, ExampleService.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isTrue();
|
||||
assertThat(excludes(filter, SecurityFilterChain.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleModule.class)).isTrue();
|
||||
}
|
||||
@@ -116,6 +120,7 @@ class WebMvcTypeExcludeFilterTests {
|
||||
assertThat(excludes(filter, ExampleService.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
|
||||
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
|
||||
assertThat(excludes(filter, SecurityFilterChain.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse();
|
||||
assertThat(excludes(filter, ExampleModule.class)).isFalse();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user