Merge branch '3.0.x'

Closes gh-35171
This commit is contained in:
Andy Wilkinson 2023-04-26 12:10:34 +01:00
commit b03f1e47d0
1 changed files with 9 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
@ -63,6 +64,7 @@ import org.springframework.security.web.server.MatcherSecurityWebFilterChain;
import org.springframework.security.web.server.WebFilterChainProxy; import org.springframework.security.web.server.WebFilterChainProxy;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher; import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers; import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
import org.springframework.util.function.SingletonSupplier;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilter;
@ -154,8 +156,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
static class IgnoredPathsSecurityConfiguration { static class IgnoredPathsSecurityConfiguration {
@Bean @Bean
WebFilterChainPostProcessor webFilterChainPostProcessor( static WebFilterChainPostProcessor webFilterChainPostProcessor(
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) { ObjectProvider<CloudFoundryWebFluxEndpointHandlerMapping> handlerMapping) {
return new WebFilterChainPostProcessor(handlerMapping); return new WebFilterChainPostProcessor(handlerMapping);
} }
@ -163,16 +165,17 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
static class WebFilterChainPostProcessor implements BeanPostProcessor { static class WebFilterChainPostProcessor implements BeanPostProcessor {
private final PathMappedEndpoints pathMappedEndpoints; private Supplier<PathMappedEndpoints> pathMappedEndpoints;
WebFilterChainPostProcessor(CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) { WebFilterChainPostProcessor(ObjectProvider<CloudFoundryWebFluxEndpointHandlerMapping> handlerMapping) {
this.pathMappedEndpoints = new PathMappedEndpoints(BASE_PATH, handlerMapping::getAllEndpoints); this.pathMappedEndpoints = SingletonSupplier
.of(() -> new PathMappedEndpoints(BASE_PATH, () -> handlerMapping.getObject().getAllEndpoints()));
} }
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof WebFilterChainProxy webFilterChainProxy) { if (bean instanceof WebFilterChainProxy webFilterChainProxy) {
return postProcess(webFilterChainProxy, this.pathMappedEndpoints); return postProcess(webFilterChainProxy, this.pathMappedEndpoints.get());
} }
return bean; return bean;
} }