I have define a JwtAuthenticationGatewayFilter
in spring gateway, now I define a list that store the url need to ignore with token valid like this:
public static Predicate<ServerHttpRequest> isApiSecured;
@PostConstruct
public void initExcludePath(){
isApiSecured = r -> {
List<String> excludeList = loginExcludeUrl.getExclude();
return excludeList.stream()
.noneMatch(uri -> r.getURI().getPath().equals(uri));};
}
the loginExcludeUrl.getExclude()
will get the ignore urls list(hundreds or thousands). when in the filter using this function to know ignore the url or not:
if (isApiSecured.test(request)) {
return authImpl(request, exchange, chain);
}
I am worry about when the ignore list increase, the whole website performance will slow down because every request should apply the list filter. is there any better way to ignore the url? Some of the url config like this:
login-check-path:
exclude:
- /post/user/reg
- /login
- /post/user/login
- /post/user/plugin/login
- /post/user/sms
- /post/auth/access_token/refresh
- /post/auth/refresh_token/refresh
- /post/article/newstories
- /post/article/originalstories
- /post/article/officialstories
- /post/article/share
- /post/article/read
- /post/article/detail
- /post/wechat/util/verifyWxToken
- /post/wechat/login/getQRCodeUrl
- /post/wechat/login/wxCallBack
- /post/alipay/login/alipayCallBack
- /post/alipay/login/getQRCodeUrl
- /post/alipay/notification/v1/alipaySeverNotification
- /post/websocket
- /manage/admin/user/login
- /dict/user/plugin/login
- /dict/user/login
- /dict/auth/access_token/refresh
- /dict/auth/refresh_token/refresh
- /fortune/user/login
- /fortune/user/guest/login
- /fortune/user/sms
- /fortune/user/reg/verify
- /fortune/auth/access-token/refresh
- /tik/user/login
- /tik/user/guest/login
- /tik/user/sms
- /tik/user/reg/verify