-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
While updating our security configurations as part of the Spring Boot 3.0.0 upgrade, I noticed a mismatch between the upgrade documentation on the new securityMatcher
methods. The last code sample in https://docs.spring.io/spring-security/reference/5.8/migration/servlet/config.html#use-new-security-matchers shows the following snippet:
import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.securityMatcher(antMatcher("/api/**"), antMatcher("/app/**"))
.authorizeHttpRequests((authz) -> authz
.requestMatchers(antMatcher("/api/admin/**")).hasRole("ADMIN")
.anyRequest().authenticated()
);
return http.build();
}
However http.securityMatcher(antMatcher("/api/**"), antMatcher("/app/**"))
is not possible at the moment. There is no public HttpSecurity securityMatcher(RequestMatcher... requestMatcher)
method only a public HttpSecurity securityMatcher(RequestMatcher requestMatcher)
method (no varargs) is available.
Can you please clarify in the docs how such a use case should be migrated? Thanks!
I now opted for the following variant, as I wanted to use the antMatcher explicitly: http.securityMatchers().requestMatchers(antMatcher("/api/**"), antMatcher("/app/**"))