From 15a3d08059f6a0580a8586e50b937e422a9b3018 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 17 Apr 2025 14:53:11 +0100 Subject: [PATCH] Adapt to deprecation of MvcRequestMatcher See gh-45147 --- .../actuator/customsecurity/SecurityConfiguration.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java index 9bbb126d5c..2645683631 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java @@ -30,7 +30,6 @@ import org.springframework.security.core.userdetails.User.UserBuilder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.SecurityFilterChain; -import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher; import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher; import org.springframework.web.servlet.handler.HandlerMappingIntrospector; @@ -58,18 +57,17 @@ public class SecurityConfiguration { } @Bean - @SuppressWarnings("removal") SecurityFilterChain configure(HttpSecurity http, HandlerMappingIntrospector handlerMappingIntrospector) throws Exception { http.authorizeHttpRequests((requests) -> { - requests.requestMatchers(new MvcRequestMatcher(handlerMappingIntrospector, "/actuator/beans")) + requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/actuator/beans")) .hasRole("BEANS"); requests.requestMatchers(EndpointRequest.to("health")).permitAll(); requests.requestMatchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class)) .hasRole("ACTUATOR"); requests.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll(); requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/foo")).permitAll(); - requests.requestMatchers(new MvcRequestMatcher(handlerMappingIntrospector, "/error")).permitAll(); + requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/error")).permitAll(); requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/**")).hasRole("USER"); }); http.cors(withDefaults());