Commit 10cfd34c authored by 唐峰's avatar 唐峰

请求头渠道兼容非法数字进行处理

parent 73a5fa24
......@@ -63,6 +63,7 @@ public interface IBaseController {
}
default Long getRegisteredFrom() {
try {
String from = getRequest().getHeader(Constants.X_AUTH_FROM);
if (StringUtils.isNotEmpty(from)) {
return Long.parseLong(from);
......@@ -71,7 +72,10 @@ public interface IBaseController {
if (StringUtils.isNotEmpty(from)) {
return Long.parseLong(from);
}
return null;
return 0L;
} catch (NumberFormatException e) {
return 0L;
}
}
default SessionStruct getCurrentSessionFromRedis() {
......
......@@ -40,7 +40,11 @@ public class InnerInterceptor implements HandlerInterceptor {
//所有开放出去的外部接口,都需要验证租户id和注册来源
String tenantId = request.getHeader(Constants.X_AUTH_TENANT);
String registeredFrom = request.getHeader(Constants.X_AUTH_FROM);
try {
registeredFrom = org.apache.commons.lang3.StringUtils.isEmpty(registeredFrom) ? request.getHeader(Constants.X_AUTH_FROM_) : registeredFrom;
} catch (Exception e) {
registeredFrom = "0";
}
String stmsToken = request.getHeader(Constants.X_AUTH_TOKEN);
if (StringUtils.isEmpty(tenantId)) {
throw new BizException(BizExceptionEnum.UN_EXIT_TENANT_ID);
......
......@@ -13,6 +13,7 @@ import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.StringUtils;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
......@@ -109,8 +110,11 @@ public class RequestFilter implements Filter {
private void printReqLog(CustomHeaderRequestWrapper request) {
try {
Map<String, String> headerMap = processHeader(request);
String url = request.getRequestURL().toString();
if (!StringUtils.isEmpty(url) && url.contains("/tech/health/check") ) {
return;
}
Map<String, String> headerMap = processHeader(request);
Map<String, String> requestParamMap = Maps.newHashMap();
CustomHeaderRequestWrapper requestWrapper = new CustomHeaderRequestWrapper(request);
requestParamMap.put("请求参数", requestWrapper.getRequestParam());
......
......@@ -131,7 +131,11 @@ public class XyqbSessionContextHolder {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader(Constants.X_AUTH_TOKEN);
String from = request.getHeader(Constants.X_AUTH_FROM);
try {
from = StringUtils.isEmpty(from) ? request.getHeader(Constants.X_AUTH_FROM_) : from;
} catch (Exception e) {
from = "0";
}
int tenantId= UserConstant.defaultTenantId;
String tenantIdString = request.getHeader(Constants.X_AUTH_TENANT);
if(StringUtils.isNotEmpty(tenantIdString)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment