org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers Java Examples

The following examples show how to use org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActuatorSecurityFluxConfig.java    From foremast with Apache License 2.0 5 votes vote down vote up
@Bean
public SecurityWebFilterChain apiHttpSecurity(
        ServerHttpSecurity http) {
    if (k8sMetricsProperties.isDisableCsrf()) {
        http.csrf().disable();
    }
    http.securityMatcher(ServerWebExchangeMatchers.pathMatchers("/actuator/info", "/actuator/health", "/actuator/prometheus", "/metrics", "/actuator/k8s-metrics/*"))
            .authorizeExchange().anyExchange().permitAll();
    return http.build();
}
 
Example #2
Source File: CachingHttpHeadersFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
    return ServerWebExchangeMatchers.pathMatchers("/i18n/**", "/content/**", "/app/**")
        .matches(exchange)
        .filter(ServerWebExchangeMatcher.MatchResult::isMatch)
        .doOnNext(matchResult -> {
            ServerHttpResponse response = exchange.getResponse();
            response.getHeaders().setCacheControl("max-age=" + cacheTimeToLive + ", public");
            response.getHeaders().setPragma("cache");
            response.getHeaders().setExpires(cacheTimeToLive + System.currentTimeMillis());

        })
        .then(Mono.defer(() -> chain.filter(exchange)));
}
 
Example #3
Source File: AbstractServerWebExchangeMatcherRegistry.java    From spring-security-reactive with Apache License 2.0 2 votes vote down vote up
/**
 * Maps any request.
 *
 * @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
 */
public T anyExchange() {
	return matcher(ServerWebExchangeMatchers.anyExchange());
}
 
Example #4
Source File: AbstractServerWebExchangeMatcherRegistry.java    From spring-security-reactive with Apache License 2.0 2 votes vote down vote up
/**
 * Maps a {@link List} of
 * {@link org.springframework.security.web.server.util.matcher.PathMatcherServerWebExchangeMatcher}
 * instances.
 *
 * @param method the {@link HttpMethod} to use or {@code null} for any
 * {@link HttpMethod}.
 * @param antPatterns the ant patterns to create. If {@code null} or empty, then matches on nothing.
 * {@link org.springframework.security.web.server.util.matcher.PathMatcherServerWebExchangeMatcher} from
 *
 * @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
 */
public T antMatchers(HttpMethod method, String... antPatterns) {
	return matcher(ServerWebExchangeMatchers.antMatchers(method, antPatterns));
}
 
Example #5
Source File: AbstractServerWebExchangeMatcherRegistry.java    From spring-security-reactive with Apache License 2.0 2 votes vote down vote up
/**
 * Maps a {@link List} of
 * {@link org.springframework.security.web.server.util.matcher.PathMatcherServerWebExchangeMatcher}
 * instances that do not care which {@link HttpMethod} is used.
 *
 * @param antPatterns the ant patterns to create
 * {@link org.springframework.security.web.server.util.matcher.PathMatcherServerWebExchangeMatcher} from
 *
 * @return the object that is chained after creating the {@link ServerWebExchangeMatcher}
 */
public T antMatchers(String... antPatterns) {
	return matcher(ServerWebExchangeMatchers.antMatchers(antPatterns));
}