Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
sts网站
Commits
b9f45057
Commit
b9f45057
authored
Aug 10, 2022
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
操作日志记录支持排除敏感属性字段
parent
89008c28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+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
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/filter/PropertyPreExcludeFilter.java
0 → 100644
View file @
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
View file @
b9f45057
...
@@ -19,10 +19,11 @@ import com.ruoyi.common.annotation.Log;
...
@@ -19,10 +19,11 @@ import com.ruoyi.common.annotation.Log;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.enums.BusinessStatus
;
import
com.ruoyi.common.enums.BusinessStatus
;
import
com.ruoyi.common.enums.HttpMethod
;
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.ServletUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.ip.IpUtils
;
import
com.ruoyi.common.utils.ip.IpUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.framework.manager.AsyncManager
;
import
com.ruoyi.framework.manager.AsyncManager
;
import
com.ruoyi.framework.manager.factory.AsyncFactory
;
import
com.ruoyi.framework.manager.factory.AsyncFactory
;
import
com.ruoyi.system.domain.SysOperLog
;
import
com.ruoyi.system.domain.SysOperLog
;
...
@@ -38,6 +39,9 @@ public class LogAspect
...
@@ -38,6 +39,9 @@ public class LogAspect
{
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LogAspect
.
class
);
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
...
@@ -168,7 +172,7 @@ public class LogAspect
{
{
try
try
{
{
Object
jsonObj
=
JSON
.
toJSON
(
o
);
String
jsonObj
=
JSON
.
toJSONString
(
o
,
excludePropertyPreFilter
()
);
params
+=
jsonObj
.
toString
()
+
" "
;
params
+=
jsonObj
.
toString
()
+
" "
;
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
@@ -180,6 +184,14 @@ public class LogAspect
...
@@ -180,6 +184,14 @@ public class LogAspect
return
params
.
trim
();
return
params
.
trim
();
}
}
/**
* 忽略敏感属性
*/
public
PropertyPreExcludeFilter
excludePropertyPreFilter
()
{
return
new
PropertyPreExcludeFilter
().
addExcludes
(
EXCLUDE_PROPERTIES
);
}
/**
/**
* 判断是否需要过滤的对象。
* 判断是否需要过滤的对象。
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment