public EndpointServerWebExchangeMatcher excluding(String... endpoints) { List<Object> excludes = new ArrayList<>(this.excludes); excludes.addAll(Arrays.asList((Object[]) endpoints)); return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks); }
private ServerWebExchangeMatcher createDelegate( Supplier<PathMappedEndpoints> pathMappedEndpoints) { try { return createDelegate(pathMappedEndpoints.get()); } catch (NoSuchBeanDefinitionException ex) { return EMPTY_MATCHER; } }
private ServerWebExchangeMatcher createDelegate( PathMappedEndpoints pathMappedEndpoints) { Set<String> paths = new LinkedHashSet<>(); if (this.includes.isEmpty()) { paths.addAll(pathMappedEndpoints.getAllPaths()); } streamPaths(this.includes, pathMappedEndpoints).forEach(paths::add); streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove); List<ServerWebExchangeMatcher> delegateMatchers = getDelegateMatchers(paths); if (this.includeLinks && StringUtils.hasText(pathMappedEndpoints.getBasePath())) { delegateMatchers.add(new PathPatternParserServerWebExchangeMatcher( pathMappedEndpoints.getBasePath())); } return new OrServerWebExchangeMatcher(delegateMatchers); }
public EndpointServerWebExchangeMatcher excludingLinks() { return new EndpointServerWebExchangeMatcher(this.includes, this.excludes, false); }
/** * Returns a matcher that includes all {@link Endpoint actuator endpoints}. It also * includes the links endpoint which is present at the base path of the actuator * endpoints. The {@link EndpointServerWebExchangeMatcher#excluding(Class...) * excluding} method can be used to further remove specific endpoints if required. For * example: <pre class="code"> * EndpointRequest.toAnyEndpoint().excluding(ShutdownEndpoint.class) * </pre> * @return the configured {@link ServerWebExchangeMatcher} */ public static EndpointServerWebExchangeMatcher toAnyEndpoint() { return new EndpointServerWebExchangeMatcher(true); }
@Override protected void initialized(Supplier<PathMappedEndpoints> pathMappedEndpoints) { this.delegate = createDelegate(pathMappedEndpoints); }
public EndpointServerWebExchangeMatcher excluding(Class<?>... endpoints) { List<Object> excludes = new ArrayList<>(this.excludes); excludes.addAll(Arrays.asList((Object[]) endpoints)); return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks); }
/** * Returns a matcher that includes the specified {@link Endpoint actuator endpoints}. * For example: <pre class="code"> * EndpointRequest.to("shutdown", "health") * </pre> * @param endpoints the endpoints to include * @return the configured {@link ServerWebExchangeMatcher} */ public static EndpointServerWebExchangeMatcher to(String... endpoints) { return new EndpointServerWebExchangeMatcher(endpoints, false); }
private EndpointId getEndpointId(Object source) { if (source instanceof EndpointId) { return (EndpointId) source; } if (source instanceof String) { return (EndpointId.of((String) source)); } if (source instanceof Class) { return getEndpointId((Class<?>) source); } throw new IllegalStateException("Unsupported source " + source); }
/** * Returns a matcher that includes the specified {@link Endpoint actuator endpoints}. * For example: <pre class="code"> * EndpointRequest.to(ShutdownEndpoint.class, HealthEndpoint.class) * </pre> * @param endpoints the endpoints to include * @return the configured {@link ServerWebExchangeMatcher} */ public static EndpointServerWebExchangeMatcher to(Class<?>... endpoints) { return new EndpointServerWebExchangeMatcher(endpoints, false); }
@Bean public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { return http .authorizeExchange() .matchers(EndpointRequest.toAnyEndpoint() .excluding("prometheus")).authenticated() .anyExchange().permitAll().and() .formLogin().and() .httpBasic().and() .build(); }