From 59f08e861e9d01f69821d3340dc7910a174ce0b2 Mon Sep 17 00:00:00 2001 From: Josh Cummings <3627351+jzheaux@users.noreply.github.com> Date: Wed, 26 Mar 2025 12:46:45 -0600 Subject: [PATCH] Use PathPatternRequestMatcher in Docs Update documenation references from PathPatternRequestMatcher to AntPathRequestMatcher Issue gh-16632 --- .../security/config/annotation/web/builders/HttpSecurity.java | 4 ++-- .../config/annotation/web/configurers/LogoutConfigurer.java | 4 ++-- .../security/config/annotation/web/HttpSecurityDsl.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java b/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java index f592b34481..0727ba33bd 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java @@ -3706,8 +3706,8 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder - * @param requestMatcher the {@link RequestMatcher} to use (i.e. new - * AntPathRequestMatcher("/admin/**","GET") ) + * @param requestMatcher the {@link RequestMatcher} to use, for example, + * {@code PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GET, "/admin/**")} * @return the {@link HttpSecurity} for further customizations * @see #securityMatcher(String...) */ diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java index 7797a88f4b..3c89ccbaf4 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/LogoutConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ public final class LogoutConfigurer> * (i.e. log out) to protect against * CSRF * attacks. If you really want to use an HTTP GET, you can use - * logoutRequestMatcher(new AntPathRequestMatcher(logoutUrl, "GET")); + * logoutRequestMatcher(PathPatternRequestMatcher.withDefaults().matcher(HttpMethod.GEt, logoutUrl)); *

* @param logoutUrl the URL that will invoke logout. * @return the {@link LogoutConfigurer} for further customization diff --git a/config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt b/config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt index a0e3b48ca2..b1246a122a 100644 --- a/config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt +++ b/config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -192,7 +192,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu * @Bean * fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { * http { - * securityMatcher(AntPathRequestMatcher("/private/**")) + * securityMatcher(PathPatternRequestMatcher.withDefaults().matcher("/private/**")) * formLogin { * loginPage = "/log-in" * }