update README.md.
parent
5d2835f418
commit
aceb32973c
189
README.md
189
README.md
|
@ -1,13 +1,19 @@
|
|||
# desensitize
|
||||
# 数据脱敏工具
|
||||
|
||||
#### 介绍
|
||||
数据脱敏工具包
|
||||
#### 一、介绍
|
||||
1. 支持13种类型数据的脱敏,例如:邮箱地址、手机号、身份证、银行卡、车牌号、姓名、家庭地址、ip地址、生日、密码等
|
||||
2. 配置灵活,同时支持全局脱敏和局部脱敏
|
||||
3. 任意对象都可以被脱敏
|
||||
4. 支持jsonpath表达式,可灵活控制同一个对象不同层级关系时既要脱敏又要不脱敏的场景
|
||||
---
|
||||
#### 二、软件架构
|
||||
|
||||
#### 软件架构
|
||||
待补充
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
#### 安装教程
|
||||
#### 三、快速入门
|
||||
|
||||
1. 添加依赖
|
||||
```
|
||||
|
@ -35,37 +41,178 @@ public class DemoApplication {
|
|||
```
|
||||
3. 针对方法的局部脱敏 @Desensitize
|
||||
```
|
||||
@RequestMapping("4")
|
||||
@RequestMapping("queryResult")
|
||||
@Desensitize(fieldMapping = @FieldMapping(fields = {"_mobile"},type = DesensitizeType.MOBILE))
|
||||
public Result demo4() {
|
||||
return new Result("111111111@163.com","17622233344");
|
||||
public Result queryResult() {
|
||||
return new Result("123456789@163.com","17622233344");
|
||||
}
|
||||
```
|
||||
|
||||
4. 脱敏效果展示(响应体中的_mobile字段被脱敏了)
|
||||
```
|
||||
{
|
||||
"_email": "111111111@163.com",
|
||||
"_email": "123456789@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
#### 四、场景示例
|
||||
##### 场景一:多字段脱敏
|
||||
|
||||
###### 1.1 配置示例
|
||||
```
|
||||
@Desensitize(
|
||||
fieldMapping = {
|
||||
@FieldMapping(fields = {"_mobile"},type = DesensitizeType.MOBILE),
|
||||
@FieldMapping(fields = {"_email"},type = DesensitizeType.EMAIL)}
|
||||
)
|
||||
```
|
||||
|
||||
###### 1.2 脱敏效果
|
||||
```
|
||||
{
|
||||
"_email": "123******@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
```
|
||||
|
||||
#### 使用说明
|
||||
|
||||
|
||||
##### 场景二:多字段匹配同一种脱敏算法
|
||||
|
||||
|
||||
###### 2.1 配置示例
|
||||
```
|
||||
@Desensitize(
|
||||
fieldMapping = {
|
||||
@FieldMapping(fields = {"_mobile","phone"},type = DesensitizeType.MOBILE),
|
||||
@FieldMapping(fields = {"_email"},type = DesensitizeType.EMAIL)}
|
||||
)
|
||||
```
|
||||
|
||||
###### 2.2 脱敏效果
|
||||
|
||||
```
|
||||
{
|
||||
"phone": "123**********.com",
|
||||
"result": {
|
||||
"_email": "123******@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
##### 场景三:忽略字段名相同层级不同的字段
|
||||
###### 3.1 注解配置
|
||||
|
||||
```
|
||||
@Desensitize(
|
||||
fieldMapping = {
|
||||
@FieldMapping(fields = {"_mobile","phone"},type = DesensitizeType.MOBILE),
|
||||
@FieldMapping(fields = {"_email"},type = DesensitizeType.EMAIL)},
|
||||
ignoreByJpe = "$._mobile"
|
||||
)
|
||||
```
|
||||
###### 3.2 脱敏效果
|
||||
|
||||
```
|
||||
{
|
||||
"_mobile": "17622233345",
|
||||
"result": {
|
||||
"_email": "123******@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### 场景四:全局配置脱敏规则局部方法中使用
|
||||
###### 4.1 启动类中配置全局规则
|
||||
|
||||
```
|
||||
@SpringBootApplication
|
||||
@EnableDesensitize(
|
||||
fieldMapping = {
|
||||
@FieldMapping(fields = {"_mobile","phone"},type = DesensitizeType.MOBILE),
|
||||
@FieldMapping(fields = {"_email"},type = DesensitizeType.EMAIL)},
|
||||
ignoreByJpe = "$._mobile"
|
||||
)
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
###### 4.2 局部方法中使用全局规则
|
||||
|
||||
```
|
||||
@Desensitize
|
||||
public ApiResult queryResult() {
|
||||
return new ApiResult("17622233345",new Result("123456789@163.com","17622233344"));
|
||||
}
|
||||
```
|
||||
###### 4.3 脱敏效果
|
||||
|
||||
```
|
||||
{
|
||||
"_mobile": "17622233345",
|
||||
"result": {
|
||||
"_email": "123******@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
##### 场景五:局部方法中覆盖全局配置的脱敏规则
|
||||
###### 5.1 启动类中配置全局规则
|
||||
```
|
||||
@SpringBootApplication
|
||||
@EnableDesensitize(
|
||||
fieldMapping = {
|
||||
@FieldMapping(fields = {"_mobile","phone"},type = DesensitizeType.MOBILE),
|
||||
@FieldMapping(fields = {"_email"},type = DesensitizeType.EMAIL)},
|
||||
ignoreByJpe = "$._mobile"
|
||||
)
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
###### 5.2 局部方法中覆盖全局规则
|
||||
|
||||
```
|
||||
@Desensitize( fieldMapping = @FieldMapping(fields = {"_mobile"},type = DesensitizeType.MOBILE) )
|
||||
public ApiResult queryResult() {
|
||||
return new ApiResult("17622233345",new Result("123456789@163.com","17622233344"));
|
||||
}
|
||||
```
|
||||
###### 5.3 脱敏效果
|
||||
|
||||
```
|
||||
{
|
||||
"_mobile": "176****3345",
|
||||
"result": {
|
||||
"_email": "123456789@163.com",
|
||||
"_mobile": "176****3344"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
|
|
Loading…
Reference in New Issue