SpringWebFlux安全中的白名单端点,无上下文根路径

SpringWebFlux安全中的白名单端点,无上下文根路径,spring,spring-boot,spring-security,spring-webflux,whitelist,Spring,Spring Boot,Spring Security,Spring Webflux,Whitelist,我试图将所有以/health结尾的自定义端点列入白名单,但在WebFlux安全性中,我无法使用正则表达式匹配所有端点。e、 g./app/health、/app/meta/health、/app/custom/meta/health、/api/app/custom/meta/health等。在构建SecurityWebFilterChain时,我没有发现任何模式(或正则表达式)可以用一个条目将这些端点列入白名单。 如果我尝试使用正则表达式,我也会收到警告 spring-security '**'

我试图将所有以/health结尾的自定义端点列入白名单,但在WebFlux安全性中,我无法使用正则表达式匹配所有端点。e、 g./app/health、/app/meta/health、/app/custom/meta/health、/api/app/custom/meta/health等。在构建SecurityWebFilterChain时,我没有发现任何模式(或正则表达式)可以用一个条目将这些端点列入白名单。 如果我尝试使用正则表达式,我也会收到警告

spring-security '**' patterns are not supported in the middle of patterns and will be rejected in the future. Consider using '*' instead for matching a single path segment.
下面是代码片段

String[] ALLOWED_PATTERNS = {".*/health"};
// String[] ALLOWED_PATTERNS = {"/*/health"};  // allows whitelist /app/health endpoint
// String[] ALLOWED_PATTERNS = {"/*/health", "/*/*/health"};  // need generic way to whitelist all

@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) {
    return http
        .authorizeExchange()
        .pathMatchers(ALLOWED_PATTERNS).permitAll()
        .anyExchange().authenticated()
         ...
        .build();
}
通过提供antMatchers,我可以在Spring中实现同样的安全性(不是被动/web流量安全性)

@Override
public void configure(WebSecurity web) {
   web.ignoring().antMatchers("/**/health");
}
注意:这不是spring执行器运行状况端点,而是自定义运行状况端点