Skip to content

Commit 3ab6bee

Browse files
committed
Make method static to prevent circular dependency error
Workaround for circular dependency between ServerHttpSecurityConfiguration and WebFluxConfigurationSupport. Closes gh-10076
1 parent 6d6dc11 commit 3ab6bee

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -89,7 +89,7 @@ void setUserDetailsPasswordService(ReactiveUserDetailsPasswordService userDetail
8989
}
9090

9191
@Bean
92-
WebFluxConfigurer authenticationPrincipalArgumentResolverConfigurer(
92+
static WebFluxConfigurer authenticationPrincipalArgumentResolverConfigurer(
9393
ObjectProvider<AuthenticationPrincipalArgumentResolver> authenticationPrincipalArgumentResolver) {
9494
return new WebFluxConfigurer() {
9595

config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -32,6 +32,7 @@
3232
import org.springframework.core.io.buffer.DataBuffer;
3333
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
3434
import org.springframework.http.MediaType;
35+
import org.springframework.mock.web.MockServletContext;
3536
import org.springframework.security.authentication.TestingAuthenticationToken;
3637
import org.springframework.security.config.test.SpringTestContext;
3738
import org.springframework.security.config.test.SpringTestContextExtension;
@@ -64,6 +65,7 @@
6465
import org.springframework.util.MultiValueMap;
6566
import org.springframework.web.bind.annotation.GetMapping;
6667
import org.springframework.web.bind.annotation.RestController;
68+
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
6769
import org.springframework.web.reactive.config.DelegatingWebFluxConfiguration;
6870
import org.springframework.web.reactive.config.EnableWebFlux;
6971
import org.springframework.web.reactive.function.BodyInserters;
@@ -307,6 +309,17 @@ public void resolveAuthenticationPrincipalArgumentResolverFirstDoesNotCauseBeanC
307309
DelegatingWebFluxConfiguration.class).autowire();
308310
}
309311

312+
@Test
313+
// gh-10076
314+
public void webFluxConfigurationSupportAndServerHttpSecurityConfigurationDoNotCauseCircularReference() {
315+
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
316+
context.setAllowCircularReferences(false);
317+
context.register(EnableWebFluxSecurityConfiguration.class, ReactiveAuthenticationTestConfiguration.class,
318+
DelegatingWebFluxConfiguration.class);
319+
context.setServletContext(new MockServletContext());
320+
context.refresh();
321+
}
322+
310323
@EnableWebFluxSecurity
311324
@Import(ReactiveAuthenticationTestConfiguration.class)
312325
static class Config {

0 commit comments

Comments
 (0)