Skip to content

Commit dd20f06

Browse files
Merge branch '6.1.x' into 6.2.x
Closes gh-14380
2 parents f95cda6 + 7cd626f commit dd20f06

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebMvcSecurityConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
import org.springframework.security.web.SecurityFilterChain;
4949
import org.springframework.security.web.access.HandlerMappingIntrospectorRequestTransformer;
5050
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
51+
import org.springframework.security.web.debug.DebugFilter;
5152
import org.springframework.security.web.firewall.HttpFirewall;
5253
import org.springframework.security.web.firewall.RequestRejectedHandler;
5354
import org.springframework.security.web.method.annotation.AuthenticationPrincipalArgumentResolver;
@@ -323,6 +324,9 @@ private static FilterChainProxy findFilterChainProxy(List<? extends Filter> filt
323324
if (filter instanceof FilterChainProxy fcp) {
324325
return fcp;
325326
}
327+
if (filter instanceof DebugFilter debugFilter) {
328+
return debugFilter.getFilterChainProxy();
329+
}
326330
}
327331
throw new IllegalStateException("Couldn't find FilterChainProxy in " + filters);
328332
}

config/src/test/java/org/springframework/security/config/annotation/web/configuration/EnableWebSecurityTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
3535
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
3636

3737
import static org.assertj.core.api.Assertions.assertThat;
38+
import static org.assertj.core.api.Assertions.assertThatNoException;
3839
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication;
3940
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
4041
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@@ -56,6 +57,12 @@ public void loadConfigWhenChildConfigExtendsSecurityConfigThenSecurityConfigInhe
5657
this.spring.getContext().getBean("springSecurityFilterChain", DebugFilter.class);
5758
}
5859

60+
// gh-14370
61+
@Test
62+
public void loadConfigWhenEnableWebMvcDebugConfigThenContextIsBuilt() {
63+
assertThatNoException().isThrownBy(() -> this.spring.register(EnableWebMvcDebugConfig.class).autowire());
64+
}
65+
5966
@Test
6067
public void configureWhenEnableWebMvcThenAuthenticationPrincipalResolvable() throws Exception {
6168
this.spring.register(AuthenticationPrincipalConfig.class).autowire();
@@ -86,6 +93,13 @@ public void enableWebSecurityWhenProxyBeanMethodsFalseThenBeanProxyingDisabled()
8693
assertThat(parentBean.getChild()).isNotSameAs(childBean);
8794
}
8895

96+
@Configuration
97+
@EnableWebMvc
98+
@EnableWebSecurity(debug = true)
99+
static class EnableWebMvcDebugConfig {
100+
101+
}
102+
89103
@Configuration
90104
static class ChildSecurityConfig extends DebugSecurityConfig {
91105

0 commit comments

Comments
 (0)