mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-01-13 07:05:11 +08:00
update 优化 接口访问日志 排除敏感参数输出
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package org.dromara.gateway.filter;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.gateway.config.properties.ApiDecryptProperties;
|
||||
import org.dromara.gateway.config.properties.CustomGatewayProperties;
|
||||
@@ -17,6 +19,9 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 全局日志过滤器
|
||||
* <p>
|
||||
@@ -51,11 +56,26 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
|
||||
log.info("[PLUS]开始请求 => URL[{}],参数类型[encrypt]", url);
|
||||
} else {
|
||||
String jsonParam = WebFluxUtils.resolveBodyFromCacheRequest(exchange);
|
||||
List<Dict> list = new ArrayList<>();
|
||||
if (JsonUtils.isJsonArray(jsonParam)) {
|
||||
List<String> list1 = JsonUtils.parseArray(jsonParam, String.class);
|
||||
for (String str : list1) {
|
||||
Dict map = JsonUtils.parseMap(str);
|
||||
MapUtil.removeAny(map, SystemConstants.EXCLUDE_PROPERTIES);
|
||||
list.add(map);
|
||||
}
|
||||
jsonParam = JsonUtils.toJsonString(list);
|
||||
} else {
|
||||
Dict map = JsonUtils.parseMap(jsonParam);
|
||||
MapUtil.removeAny(map, SystemConstants.EXCLUDE_PROPERTIES);
|
||||
jsonParam = JsonUtils.toJsonString(map);
|
||||
}
|
||||
log.info("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
|
||||
}
|
||||
} else {
|
||||
MultiValueMap<String, String> parameterMap = request.getQueryParams();
|
||||
if (MapUtil.isNotEmpty(parameterMap)) {
|
||||
MapUtil.removeAny(parameterMap, SystemConstants.EXCLUDE_PROPERTIES);
|
||||
String parameters = JsonUtils.toJsonString(parameterMap);
|
||||
log.info("[PLUS]开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user