Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
b9f45057
提交
b9f45057
authored
8月 10, 2022
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
操作日志记录支持排除敏感属性字段
上级
89008c28
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
2 行删除
+38
-2
PropertyPreExcludeFilter.java
...ava/com/ruoyi/common/filter/PropertyPreExcludeFilter.java
+24
-0
LogAspect.java
.../src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
+14
-2
没有找到文件。
ruoyi-common/src/main/java/com/ruoyi/common/filter/PropertyPreExcludeFilter.java
0 → 100644
浏览文件 @
b9f45057
package
com
.
ruoyi
.
common
.
filter
;
import
com.alibaba.fastjson2.filter.SimplePropertyPreFilter
;
/**
* 排除JSON敏感属性
*
* @author ruoyi
*/
public
class
PropertyPreExcludeFilter
extends
SimplePropertyPreFilter
{
public
PropertyPreExcludeFilter
()
{
}
public
PropertyPreExcludeFilter
addExcludes
(
String
...
filters
)
{
for
(
int
i
=
0
;
i
<
filters
.
length
;
i
++)
{
this
.
getExcludes
().
add
(
filters
[
i
]);
}
return
this
;
}
}
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
浏览文件 @
b9f45057
...
...
@@ -19,10 +19,11 @@ import com.ruoyi.common.annotation.Log;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.enums.BusinessStatus
;
import
com.ruoyi.common.enums.HttpMethod
;
import
com.ruoyi.common.filter.PropertyPreExcludeFilter
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.ServletUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.ip.IpUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.framework.manager.AsyncManager
;
import
com.ruoyi.framework.manager.factory.AsyncFactory
;
import
com.ruoyi.system.domain.SysOperLog
;
...
...
@@ -38,6 +39,9 @@ public class LogAspect
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LogAspect
.
class
);
/** 排除敏感属性字段 */
public
static
final
String
[]
EXCLUDE_PROPERTIES
=
{
"password"
,
"oldPassword"
,
"newPassword"
,
"confirmPassword"
};
/**
* 处理完请求后执行
*
...
...
@@ -168,7 +172,7 @@ public class LogAspect
{
try
{
Object
jsonObj
=
JSON
.
toJSON
(
o
);
String
jsonObj
=
JSON
.
toJSONString
(
o
,
excludePropertyPreFilter
()
);
params
+=
jsonObj
.
toString
()
+
" "
;
}
catch
(
Exception
e
)
...
...
@@ -180,6 +184,14 @@ public class LogAspect
return
params
.
trim
();
}
/**
* 忽略敏感属性
*/
public
PropertyPreExcludeFilter
excludePropertyPreFilter
()
{
return
new
PropertyPreExcludeFilter
().
addExcludes
(
EXCLUDE_PROPERTIES
);
}
/**
* 判断是否需要过滤的对象。
*
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论