|
|
|
@ -33,10 +33,10 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoC
|
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
|
|
|
|
|
import org.springframework.boot.actuate.health.HealthEndpoint;
|
|
|
|
|
import org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtension;
|
|
|
|
@ -82,6 +82,8 @@ import org.springframework.web.server.WebFilter;
|
|
|
|
|
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
|
|
|
|
|
public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
private static final String BASE_PATH = "/cloudfoundryapplication";
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@ConditionalOnMissingBean
|
|
|
|
|
@ConditionalOnAvailableEndpoint
|
|
|
|
@ -117,9 +119,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|
|
|
|
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
|
|
|
|
|
allEndpoints.addAll(webEndpoints);
|
|
|
|
|
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
|
|
|
|
|
return new CloudFoundryWebFluxEndpointHandlerMapping(new EndpointMapping("/cloudfoundryapplication"),
|
|
|
|
|
webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor,
|
|
|
|
|
new EndpointLinksResolver(allEndpoints));
|
|
|
|
|
return new CloudFoundryWebFluxEndpointHandlerMapping(new EndpointMapping(BASE_PATH), webEndpoints,
|
|
|
|
|
endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CloudFoundrySecurityInterceptor getSecurityInterceptor(WebClient.Builder webClientBuilder,
|
|
|
|
@ -155,25 +156,33 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|
|
|
|
static class IgnoredPathsSecurityConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
WebFilterChainPostProcessor webFilterChainPostProcessor() {
|
|
|
|
|
return new WebFilterChainPostProcessor();
|
|
|
|
|
WebFilterChainPostProcessor webFilterChainPostProcessor(
|
|
|
|
|
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) {
|
|
|
|
|
return new WebFilterChainPostProcessor(handlerMapping);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class WebFilterChainPostProcessor implements BeanPostProcessor {
|
|
|
|
|
|
|
|
|
|
private final PathMappedEndpoints pathMappedEndpoints;
|
|
|
|
|
|
|
|
|
|
WebFilterChainPostProcessor(CloudFoundryWebFluxEndpointHandlerMapping handlerMapping) {
|
|
|
|
|
this.pathMappedEndpoints = new PathMappedEndpoints(BASE_PATH, handlerMapping::getAllEndpoints);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
|
|
|
|
if (bean instanceof WebFilterChainProxy) {
|
|
|
|
|
return postProcess((WebFilterChainProxy) bean);
|
|
|
|
|
return postProcess((WebFilterChainProxy) bean, this.pathMappedEndpoints);
|
|
|
|
|
}
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WebFilterChainProxy postProcess(WebFilterChainProxy existing) {
|
|
|
|
|
private WebFilterChainProxy postProcess(WebFilterChainProxy existing, PathMappedEndpoints pathMappedEndpoints) {
|
|
|
|
|
List<String> paths = getPaths(pathMappedEndpoints);
|
|
|
|
|
ServerWebExchangeMatcher cloudFoundryRequestMatcher = ServerWebExchangeMatchers
|
|
|
|
|
.pathMatchers("/cloudfoundryapplication/**");
|
|
|
|
|
.pathMatchers(paths.toArray(new String[] {}));
|
|
|
|
|
WebFilter noOpFilter = (exchange, chain) -> chain.filter(exchange);
|
|
|
|
|
MatcherSecurityWebFilterChain ignoredRequestFilterChain = new MatcherSecurityWebFilterChain(
|
|
|
|
|
cloudFoundryRequestMatcher, Collections.singletonList(noOpFilter));
|
|
|
|
@ -182,6 +191,14 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
|
|
|
|
|
return new WebFilterChainProxy(ignoredRequestFilterChain, allRequestsFilterChain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<String> getPaths(PathMappedEndpoints pathMappedEndpoints) {
|
|
|
|
|
List<String> paths = new ArrayList<>();
|
|
|
|
|
pathMappedEndpoints.getAllPaths().forEach((path) -> paths.add(path + "/**"));
|
|
|
|
|
paths.add(BASE_PATH);
|
|
|
|
|
paths.add(BASE_PATH + "/");
|
|
|
|
|
return paths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|