新增APP路由过滤,新增不需要token验证的方式

This commit is contained in:
wenc000 2020-02-10 00:15:24 +08:00
parent 7dc7598d08
commit bedc825ede
2 changed files with 20 additions and 2 deletions

View File

@ -22,7 +22,7 @@ public class FilterConfig {
public FilterRegistrationBean appFilterRegister() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new AppFilter());
filterRegistrationBean.addUrlPatterns("/app/*");
filterRegistrationBean.addUrlPatterns("/app/*", "/approute/*");
filterRegistrationBean.setName("appFilter");
filterRegistrationBean.setOrder(1);
return filterRegistrationBean;

View File

@ -33,8 +33,22 @@ public class AppFilter implements Filter {
private static final Logger LOG = LoggerFactory.getLogger(AppFilter.class);
private AntPathMatcher antPathMatcher;
/**
* APP登录
*/
private static final String URL_LOGIN = "/**/app/sign/login";
/**
* APP下载
*/
private static final String URL_DOWNLOAD_APP = "/**/app/appversion/downloadapp/**";
/**
* APP放行
*/
private static final String URL_RELEASE_APP = "/**/app/**/**release/**";
/**
* APP路由放行
*/
private static final String URL_RELEASE_APP_ROUTE = "/**/approute/**/**release/**";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@ -46,7 +60,11 @@ public class AppFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String requestUri = request.getRequestURI();
if (antPathMatcher.match(URL_LOGIN, requestUri) || antPathMatcher.match(URL_DOWNLOAD_APP, requestUri)) {
boolean matcher = antPathMatcher.match(URL_LOGIN, requestUri)
|| antPathMatcher.match(URL_DOWNLOAD_APP, requestUri)
|| antPathMatcher.match(URL_RELEASE_APP, requestUri)
|| antPathMatcher.match(URL_RELEASE_APP_ROUTE, requestUri);
if (matcher) {
filterChain.doFilter(request, response);
return;
}