This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 55daaa27b78ba3f39a82d5825b4803ea71ee01e4 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jun 26 12:04:30 2024 +0100 Fix BZ 69131 - expand allowCorsPreflight to all mapped URL patterns --- .../apache/catalina/authenticator/AuthenticatorBase.java | 10 ++++------ webapps/docs/changelog.xml | 7 +++++++ webapps/docs/config/valve.xml | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java b/java/org/apache/catalina/authenticator/AuthenticatorBase.java index fc8b13cd7a..ba5e1baa4b 100644 --- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java +++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java @@ -57,6 +57,7 @@ import org.apache.catalina.connector.Response; import org.apache.catalina.filters.CorsFilter; import org.apache.catalina.filters.RemoteIpFilter; import org.apache.catalina.realm.GenericPrincipal; +import org.apache.catalina.util.FilterUtil; import org.apache.catalina.util.SessionIdGeneratorBase; import org.apache.catalina.util.StandardSessionIdGenerator; import org.apache.catalina.valves.RemoteIpValve; @@ -628,12 +629,9 @@ public abstract class AuthenticatorBase extends ValveBase implements Authenticat for (FilterMap filterMap : context.findFilterMaps()) { if (filterMap.getFilterName().equals(filterDef.getFilterName())) { if ((filterMap.getDispatcherMapping() & FilterMap.REQUEST) > 0) { - for (String urlPattern : filterMap.getURLPatterns()) { - if ("/*".equals(urlPattern)) { - allowBypass = true; - // No need to check other patterns - break; - } + String requestPath = FilterUtil.getRequestPath(request); + if (FilterUtil.matchFiltersURL(filterMap, requestPath)) { + allowBypass = true; } } // Found mappings for CORS filter. diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4af1910b4c..bfa50bf9c8 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -119,6 +119,13 @@ Add the OpenSSL version number on the APR and OpenSSL status classes. (remm) </fix> + <fix> + <bug>69131</bug>: Expand the implementation of the <code>filter</code> + value of the Authenticator attribute <code>allowCorsPreflight</code>, so + that it applies to all requests that match the configured URL patterns + for the CORS filter, rather than only applying if the CORS filter is + mapped to <code>/*</code>. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml index 390848a3c3..1c9ae867b8 100644 --- a/webapps/docs/config/valve.xml +++ b/webapps/docs/config/valve.xml @@ -1447,7 +1447,8 @@ <code>filter</code> means that a request will bypass authentication if it appears to be a CORS preflight request; it is mapped to a web application that has the <a href="filter.html#CORS_Filter">CORS - Filter</a> enabled; and the CORS Filter is mapped to <code>/*</code>. + Filter</a> enabled; and the request matches the URLPatterns for the CORS + fitler mapper. <code>always</code> means that all requests that appear to be CORS preflight requests will bypass authentication. If not set, the default value is <code>never</code>.</p> @@ -1614,7 +1615,8 @@ <code>filter</code> means that a request will bypass authentication if it appears to be a CORS preflight request; it is mapped to a web application that has the <a href="filter.html#CORS_Filter">CORS - Filter</a> enabled; and the CORS Filter is mapped to <code>/*</code>. + Filter</a> enabled; and the request matches the URLPatterns for the CORS + fitler mapper. <code>always</code> means that all requests that appear to be CORS preflight requests will bypass authentication. If not set, the default value is <code>never</code>.</p> @@ -1796,7 +1798,8 @@ <code>filter</code> means that a request will bypass authentication if it appears to be a CORS preflight request; it is mapped to a web application that has the <a href="filter.html#CORS_Filter">CORS - Filter</a> enabled; and the CORS Filter is mapped to <code>/*</code>. + Filter</a> enabled; and the request matches the URLPatterns for the CORS + fitler mapper. <code>always</code> means that all requests that appear to be CORS preflight requests will bypass authentication. If not set, the default value is <code>never</code>.</p> @@ -1944,7 +1947,8 @@ <code>filter</code> means that a request will bypass authentication if it appears to be a CORS preflight request; it is mapped to a web application that has the <a href="filter.html#CORS_Filter">CORS - Filter</a> enabled; and the CORS Filter is mapped to <code>/*</code>. + Filter</a> enabled; and the request matches the URLPatterns for the CORS + fitler mapper. <code>always</code> means that all requests that appear to be CORS preflight requests will bypass authentication. If not set, the default value is <code>never</code>.</p> @@ -2059,7 +2063,8 @@ <code>filter</code> means that a request will bypass authentication if it appears to be a CORS preflight request and the web application the request maps to has the <a href="filter.html#CORS_Filter">CORS - Filter</a> enabled and mapped to <code>/*</code>. <code>always</code> + Filter</a> enabled; and the request matches the URLPatterns for the CORS + fitler mapper. means that all requests that appear to be CORS preflight requests will bypass authentication. If not set, the default value is <code>never</code>.</p> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org