Skip to content

建议LoginAuthenticationFilter 属性authFilterExcludeUrls配置支持uri: /xx/** #1967

@xiaoxb

Description

@xiaoxb

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

url只能精准匹配
if(authFilterExcludeUrls.contains(servletPath)) {
chain.doFilter(request, response);
return;
}

Describe what you expected to happen

// Exclude the urls which needn't auth
for (String authFilterExcludeUrl : authFilterExcludeUrls) {
if (isMatch(authFilterExcludeUrl, servletPath)) {
chain.doFilter(request, response);
return;
}
}

// 判断url是否与规则配置: ? 表示单个字符; * 表示一层路径内的任意字符串,不可跨层级; ** 表示任意层路径;
public Boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}

private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();

if (authFilterExcludeUrls.stream().anyMatch(s -> PATH_MATCHER.match(s, servletPath))) {
chain.doFilter(request, response);
return;
}

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

master

Anything else we need to know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions