WebFilterChainFilter -> WebFilterChainProxy
Issue gh-4615
This commit is contained in:
parent
cfc5572b7a
commit
d0de8d40dd
|
@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.web.server.HttpSecurity;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -49,8 +49,8 @@ public class WebFluxSecurityConfiguration {
|
|||
|
||||
@Bean(SPRING_SECURITY_WEBFILTERCHAINFILTER_BEAN_NAME)
|
||||
@Order(value = WEB_FILTER_CHAIN_FILTER_ORDER)
|
||||
public WebFilterChainFilter springSecurityWebFilterChainFilter() {
|
||||
return WebFilterChainFilter.fromSecurityWebFilterChainsList(getSecurityWebFilterChains());
|
||||
public WebFilterChainProxy springSecurityWebFilterChainFilter() {
|
||||
return WebFilterChainProxy.fromSecurityWebFilterChainsList(getSecurityWebFilterChains());
|
||||
}
|
||||
|
||||
private List<SecurityWebFilterChain> getSecurityWebFilterChains() {
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.test.web.reactive.server.WebTestClientBuilder;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.security.web.server.util.matcher.PathPatternParserServerWebExchangeMatcher;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.FluxExchangeResult;
|
||||
|
@ -60,8 +60,7 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
|
|||
public class EnableWebFluxSecurityTests {
|
||||
@RunWith(SpringRunner.class)
|
||||
public static class Defaults {
|
||||
@Autowired
|
||||
WebFilterChainFilter springSecurityFilterChain;
|
||||
@Autowired WebFilterChainProxy springSecurityFilterChain;
|
||||
|
||||
@Test
|
||||
public void defaultRequiresAuthentication() {
|
||||
|
@ -150,8 +149,7 @@ public class EnableWebFluxSecurityTests {
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
public static class CustomPasswordEncoder {
|
||||
@Autowired
|
||||
WebFilterChainFilter springSecurityFilterChain;
|
||||
@Autowired WebFilterChainProxy springSecurityFilterChain;
|
||||
|
||||
@Test
|
||||
public void passwordEncoderBeanIsUsed() {
|
||||
|
@ -196,8 +194,7 @@ public class EnableWebFluxSecurityTests {
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
public static class FormLoginTests {
|
||||
@Autowired
|
||||
WebFilterChainFilter springSecurityFilterChain;
|
||||
@Autowired WebFilterChainProxy springSecurityFilterChain;
|
||||
@Test
|
||||
public void formLoginWorks() {
|
||||
WebTestClient client = WebTestClientBuilder.bindToWebFilters(
|
||||
|
@ -238,8 +235,7 @@ public class EnableWebFluxSecurityTests {
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
public static class MultiHttpSecurity {
|
||||
@Autowired
|
||||
WebFilterChainFilter springSecurityFilterChain;
|
||||
@Autowired WebFilterChainProxy springSecurityFilterChain;
|
||||
|
||||
@Test
|
||||
public void multiWorks() {
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
|||
import org.springframework.security.htmlunit.server.WebTestClientHtmlUnitDriverBuilder;
|
||||
import org.springframework.security.test.web.reactive.server.WebTestClientBuilder;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -104,7 +104,7 @@ public class FormLoginTests {
|
|||
|
||||
WebTestClient webTestClient = WebTestClient
|
||||
.bindToController(new CustomLoginPageController(), new WebTestClientBuilder.Http200RestController())
|
||||
.webFilter(WebFilterChainFilter.fromSecurityWebFilterChains(securityWebFilter))
|
||||
.webFilter(WebFilterChainProxy.fromSecurityWebFilterChains(securityWebFilter))
|
||||
.build();
|
||||
|
||||
WebDriver driver = WebTestClientHtmlUnitDriverBuilder
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||
import org.springframework.security.authentication.ReactiveAuthenticationManager;
|
||||
import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||
import org.springframework.security.test.web.reactive.server.WebTestClientBuilder;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.security.web.server.context.SecurityContextRepository;
|
||||
import org.springframework.security.web.server.context.WebSessionSecurityContextRepository;
|
||||
import org.springframework.test.web.reactive.server.EntityExchangeResult;
|
||||
|
@ -116,7 +116,7 @@ public class HttpSecurityTests {
|
|||
}
|
||||
|
||||
private WebTestClient buildClient() {
|
||||
WebFilterChainFilter springSecurityFilterChain = WebFilterChainFilter.fromSecurityWebFilterChains(
|
||||
WebFilterChainProxy springSecurityFilterChain = WebFilterChainProxy.fromSecurityWebFilterChains(
|
||||
this.http.build());
|
||||
return WebTestClientBuilder.bindToWebFilters(springSecurityFilterChain).build();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
@ -46,8 +46,7 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
|
|||
public class HelloWebfluxFnApplicationTests {
|
||||
@Autowired
|
||||
RouterFunction<?> routerFunction;
|
||||
@Autowired
|
||||
WebFilterChainFilter springSecurityFilterChain;
|
||||
@Autowired WebFilterChainProxy springSecurityFilterChain;
|
||||
|
||||
WebTestClient rest;
|
||||
|
||||
|
|
|
@ -16,12 +16,8 @@
|
|||
package org.springframework.security.web.server;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcherEntry;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
|
@ -36,10 +32,10 @@ import reactor.core.publisher.Mono;
|
|||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
public class WebFilterChainFilter implements WebFilter {
|
||||
public class WebFilterChainProxy implements WebFilter {
|
||||
private final Flux<SecurityWebFilterChain> filters;
|
||||
|
||||
public WebFilterChainFilter(Flux<SecurityWebFilterChain> filters) {
|
||||
public WebFilterChainProxy(Flux<SecurityWebFilterChain> filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
|
@ -56,15 +52,15 @@ public class WebFilterChainFilter implements WebFilter {
|
|||
.flatMap( securedChain -> securedChain.filter(exchange));
|
||||
}
|
||||
|
||||
public static WebFilterChainFilter fromWebFiltersList(List<WebFilter> filters) {
|
||||
return new WebFilterChainFilter(Flux.just(new MatcherSecurityWebFilterChain(ServerWebExchangeMatchers.anyExchange(), filters)));
|
||||
public static WebFilterChainProxy fromWebFiltersList(List<WebFilter> filters) {
|
||||
return new WebFilterChainProxy(Flux.just(new MatcherSecurityWebFilterChain(ServerWebExchangeMatchers.anyExchange(), filters)));
|
||||
}
|
||||
|
||||
public static WebFilterChainFilter fromSecurityWebFilterChainsList(List<SecurityWebFilterChain> securityWebFilterChains) {
|
||||
return new WebFilterChainFilter(Flux.fromIterable(securityWebFilterChains));
|
||||
public static WebFilterChainProxy fromSecurityWebFilterChainsList(List<SecurityWebFilterChain> securityWebFilterChains) {
|
||||
return new WebFilterChainProxy(Flux.fromIterable(securityWebFilterChains));
|
||||
}
|
||||
|
||||
public static WebFilterChainFilter fromSecurityWebFilterChains(SecurityWebFilterChain... securityWebFilterChains) {
|
||||
public static WebFilterChainProxy fromSecurityWebFilterChains(SecurityWebFilterChain... securityWebFilterChains) {
|
||||
return fromSecurityWebFilterChainsList(Arrays.asList(securityWebFilterChains));
|
||||
}
|
||||
}
|
|
@ -17,14 +17,13 @@ package org.springframework.security.test.web.reactive.server;
|
|||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
import org.springframework.security.web.server.WebFilterChainFilter;
|
||||
import org.springframework.security.web.server.WebFilterChainProxy;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient.Builder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* Provides a convenient mechanism for running {@link WebTestClient} against
|
||||
|
@ -41,7 +40,7 @@ public class WebTestClientBuilder {
|
|||
}
|
||||
|
||||
public static Builder bindToWebFilters(SecurityWebFilterChain securityWebFilterChain) {
|
||||
return bindToWebFilters(WebFilterChainFilter.fromSecurityWebFilterChains(securityWebFilterChain));
|
||||
return bindToWebFilters(WebFilterChainProxy.fromSecurityWebFilterChains(securityWebFilterChain));
|
||||
}
|
||||
|
||||
@RestController
|
||||
|
|
Loading…
Reference in New Issue