Skip to content

Commit 15a3d08

Browse files
committed
Adapt to deprecation of MvcRequestMatcher
See gh-45147
1 parent c0125e2 commit 15a3d08

File tree

1 file changed

+2
-4
lines changed
  • spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity

1 file changed

+2
-4
lines changed

Diff for: spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.security.core.userdetails.UserDetails;
3131
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
3232
import org.springframework.security.web.SecurityFilterChain;
33-
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
3433
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
3534
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
3635

@@ -58,18 +57,17 @@ private UserDetails createUserDetails(String username, String password, String..
5857
}
5958

6059
@Bean
61-
@SuppressWarnings("removal")
6260
SecurityFilterChain configure(HttpSecurity http, HandlerMappingIntrospector handlerMappingIntrospector)
6361
throws Exception {
6462
http.authorizeHttpRequests((requests) -> {
65-
requests.requestMatchers(new MvcRequestMatcher(handlerMappingIntrospector, "/actuator/beans"))
63+
requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/actuator/beans"))
6664
.hasRole("BEANS");
6765
requests.requestMatchers(EndpointRequest.to("health")).permitAll();
6866
requests.requestMatchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class))
6967
.hasRole("ACTUATOR");
7068
requests.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll();
7169
requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/foo")).permitAll();
72-
requests.requestMatchers(new MvcRequestMatcher(handlerMappingIntrospector, "/error")).permitAll();
70+
requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/error")).permitAll();
7371
requests.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/**")).hasRole("USER");
7472
});
7573
http.cors(withDefaults());

0 commit comments

Comments
 (0)