fix #I3XU3M dev 代码无法正确退出,提示 header client 信息不存在

This commit is contained in:
lht 2021-06-29 09:44:36 +08:00
parent 67d7490292
commit 580aa3c616
1 changed files with 14 additions and 1 deletions

View File

@ -17,6 +17,7 @@
package com.pig4cloud.pig.gateway.filter; package com.pig4cloud.pig.gateway.filter;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
@ -60,10 +61,22 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory<Obje
ServerHttpRequest request = exchange.getRequest(); ServerHttpRequest request = exchange.getRequest();
boolean isAuthToken = CharSequenceUtil.containsAnyIgnoreCase(request.getURI().getPath(), boolean isAuthToken = CharSequenceUtil.containsAnyIgnoreCase(request.getURI().getPath(),
SecurityConstants.OAUTH_TOKEN_URL); SecurityConstants.OAUTH_TOKEN_URL);
// 不是登录请求直接向下执行
if (!isAuthToken) {
return chain.filter(exchange);
}
// 刷新token直接向下执行
String grantType = request.getQueryParams().getFirst("grant_type");
if (StrUtil.equals(SecurityConstants.REFRESH_TOKEN, grantType)) {
return chain.filter(exchange);
}
boolean isIgnoreClient = configProperties.getIgnoreClients().contains(WebUtils.getClientId(request)); boolean isIgnoreClient = configProperties.getIgnoreClients().contains(WebUtils.getClientId(request));
try { try {
// only oauth and the request not in ignore clients need check code. // only oauth and the request not in ignore clients need check code.
if (isAuthToken && !isIgnoreClient) { if (!isIgnoreClient) {
checkCode(request); checkCode(request);
} }
} }