报告 Spring Security 匹配器方法中与自 Spring Security 7.0 起默认使用的 PathPatternParser 不兼容的请求模式。

Spring Security 7.0 从使用 Ant 样式路径匹配 (AntPathMatcher) 切换为 PathPatternParser,对通配符段实施更严格的规则。

会标记以下模式:

不正确模式示例:


  http.authorizeHttpRequests(auth -> auth
    .requestMatchers("/api/**/admin").permitAll()   // '**' 在中间
    .requestMatchers("/{*a}/{*b}").permitAll()      // 多个 {*...} 段
  );

正确模式示例:


  http.authorizeHttpRequests(auth -> auth
    .requestMatchers("/api/admin/**").permitAll()   // '**' 在结尾
    .requestMatchers("/{*path}").permitAll()        // 单个 {*...} 段
    .requestMatchers("/api/*/details").permitAll()  // 单个 '*' 可放在任何位置
  );

该检查仅在 Spring Security 7.0 或更高版本存在且 spring.mvc.pathmatch.matching-strategy 未设置为 ant_path_matcher 时才会激活。