|
|
@ -41,6 +41,7 @@ import static com.anji.plus.gaea.constant.GaeaConstant.URL_REPLACEMENT;
|
|
|
|
public class TokenFilter implements Filter {
|
|
|
|
public class TokenFilter implements Filter {
|
|
|
|
private static final Pattern PATTERN = Pattern.compile(".*().*");
|
|
|
|
private static final Pattern PATTERN = Pattern.compile(".*().*");
|
|
|
|
private static final String USER_GUEST = "guest";
|
|
|
|
private static final String USER_GUEST = "guest";
|
|
|
|
|
|
|
|
@Value("${server.servlet.context-path:'/'}")
|
|
|
|
private static final String SLASH = "/";
|
|
|
|
private static final String SLASH = "/";
|
|
|
|
private AntPathMatcher antPathMatcher = new AntPathMatcher();
|
|
|
|
private AntPathMatcher antPathMatcher = new AntPathMatcher();
|
|
|
|
|
|
|
|
|
|
|
@ -54,7 +55,6 @@ public class TokenFilter implements Filter {
|
|
|
|
private List<String> skipAuthenticateUrls;
|
|
|
|
private List<String> skipAuthenticateUrls;
|
|
|
|
private Pattern skipAuthenticatePattern;
|
|
|
|
private Pattern skipAuthenticatePattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void init(FilterConfig filterConfig) throws ServletException {
|
|
|
|
public void init(FilterConfig filterConfig) throws ServletException {
|
|
|
|
// 生成匹配正则,跳过token验证和权限验证的url
|
|
|
|
// 生成匹配正则,跳过token验证和权限验证的url
|
|
|
@ -74,8 +74,8 @@ public class TokenFilter implements Filter {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (SLASH.equals(uri)) {
|
|
|
|
if (SLASH.equals(uri) || SLASH.concat("/").equals(uri)) {
|
|
|
|
response.sendRedirect("/index.html");
|
|
|
|
response.sendRedirect(SLASH + "/index.html");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -128,6 +128,7 @@ public class TokenFilter implements Filter {
|
|
|
|
//判断接口权限
|
|
|
|
//判断接口权限
|
|
|
|
//请求路径
|
|
|
|
//请求路径
|
|
|
|
String requestUrl = request.getRequestURI();
|
|
|
|
String requestUrl = request.getRequestURI();
|
|
|
|
|
|
|
|
String servletPath = request.getServletPath();
|
|
|
|
String methodValue = request.getMethod();
|
|
|
|
String methodValue = request.getMethod();
|
|
|
|
//请求方法+#+请求路径
|
|
|
|
//请求方法+#+请求路径
|
|
|
|
String urlKey = methodValue + GaeaConstant.URL_SPLIT + requestUrl;
|
|
|
|
String urlKey = methodValue + GaeaConstant.URL_SPLIT + requestUrl;
|
|
|
|