Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Feature #1967 LoginAuthenticationFilter authFilterExcludeUrls match supports uri like /xx/** #1971

Merged
merged 2 commits into from
Jan 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
Expand All @@ -29,7 +30,6 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

Expand All @@ -51,6 +51,8 @@
*/
@Component
public class LoginAuthenticationFilter implements Filter {

private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();

private static final String URL_SUFFIX_DOT = ".";

Expand Down Expand Up @@ -85,7 +87,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
String servletPath = httpRequest.getServletPath();

// Exclude the urls which needn't auth
if (authFilterExcludeUrls.contains(servletPath)) {
boolean authFilterExcludeMatch = authFilterExcludeUrls.stream()
.anyMatch(authFilterExcludeUrl -> PATH_MATCHER.match(authFilterExcludeUrl, servletPath));
if (authFilterExcludeMatch) {
chain.doFilter(request, response);
return;
}
Expand Down