1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Polish ignoring() log messaging

- Public API remains unchanged

Issue gh-9334
This commit is contained in:
Josh Cummings
2022-02-07 14:00:55 -07:00
parent 0be772ff5b
commit f53c65b3a0
9 changed files with 13 additions and 7410 deletions
@@ -27,7 +27,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.log.LogMessage;
import org.springframework.security.web.server.restriction.IgnoreRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
/**
@@ -49,14 +48,8 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
}
public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) {
if (requestMatcher instanceof IgnoreRequestMatcher) {
IgnoreRequestMatcher ignoreRequestMatcher = (IgnoreRequestMatcher) requestMatcher;
if (ignoreRequestMatcher.isIgnore()) {
logger.info(LogMessage.format("Will not secure %s with %s", requestMatcher, filters));
}
else {
logger.info(LogMessage.format("Will secure %s with %s", requestMatcher, filters));
}
if (!filters.isEmpty()) {
logger.info(LogMessage.format("Will not secure %s", requestMatcher));
}
else {
logger.info(LogMessage.format("Will secure %s with %s", requestMatcher, filters));
@@ -1,37 +0,0 @@
/*
* Copyright 2002-2021 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.web.server.restriction;
/**
* Indicates if the path should be ignored or not by Spring Security.
*
* @author Manuel Jordan
* @since 5.5
*/
public interface IgnoreRequestMatcher {
/**
* Establishes the path must be ignored.
*/
void ignore();
/**
* If the path should be ignored or not.
*/
boolean isIgnore();
}
@@ -21,7 +21,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.server.restriction.IgnoreRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.security.web.util.matcher.RequestVariablesExtractor;
import org.springframework.util.AntPathMatcher;
@@ -45,10 +44,9 @@ import org.springframework.web.util.UrlPathHelper;
* @author Rob Winch
* @author Eddú Meléndez
* @author Evgeniy Cheban
* @author Manuel Jordan
* @since 4.1.1
*/
public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtractor, IgnoreRequestMatcher {
public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtractor {
private final DefaultMatcher defaultMatcher = new DefaultMatcher();
@@ -60,12 +58,9 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
private String servletPath;
private boolean ignore;
public MvcRequestMatcher(HandlerMappingIntrospector introspector, String pattern) {
this.introspector = introspector;
this.pattern = pattern;
this.ignore = false;
}
@Override
@@ -134,16 +129,6 @@ public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtrac
return this.servletPath;
}
@Override
public void ignore() {
this.ignore = true;
}
@Override
public boolean isIgnore() {
return this.ignore;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -22,7 +22,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.server.restriction.IgnoreRequestMatcher;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -54,7 +53,7 @@ import org.springframework.web.util.UrlPathHelper;
* @since 3.1
* @see org.springframework.util.AntPathMatcher
*/
public final class AntPathRequestMatcher implements RequestMatcher, RequestVariablesExtractor, IgnoreRequestMatcher {
public final class AntPathRequestMatcher implements RequestMatcher, RequestVariablesExtractor {
private static final String MATCH_ALL = "/**";
@@ -68,8 +67,6 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
private final UrlPathHelper urlPathHelper;
private boolean ignore;
/**
* Creates a matcher with the specific pattern which will match all HTTP methods in a
* case sensitive manner.
@@ -135,7 +132,6 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
this.pattern = pattern;
this.httpMethod = StringUtils.hasText(httpMethod) ? HttpMethod.valueOf(httpMethod) : null;
this.urlPathHelper = urlPathHelper;
this.ignore = false;
}
/**
@@ -175,16 +171,6 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
return MatchResult.match(this.matcher.extractUriTemplateVariables(url));
}
@Override
public void ignore() {
this.ignore = true;
}
@Override
public boolean isIgnore() {
return this.ignore;
}
private String getRequestPath(HttpServletRequest request) {
if (this.urlPathHelper != null) {
return this.urlPathHelper.getPathWithinApplication(request);