Skip to content

Commit

Permalink
dashboard: authFilterExcludeUrls supports matching path pattern like …
Browse files Browse the repository at this point in the history
…/xx/** (alibaba#1971)
  • Loading branch information
brotherlu-xcq authored and taz committed Aug 15, 2021
1 parent f1c60c9 commit 61def81
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 61def81

Please sign in to comment.