data-shield-spring-boot-starter

data-shield spring-boot

License

License

Categories

Categories

Spring Boot Container Microservices Ant Build Tools Data
GroupId

GroupId

com.github.homeant
ArtifactId

ArtifactId

data-shield-spring-boot-starter
Last Version

Last Version

1.0-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

data-shield-spring-boot-starter
data-shield spring-boot
Project URL

Project URL

https://github.com/homeant/data-shield
Source Code Management

Source Code Management

https://github.com/homeant/data-shield

Download data-shield-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.homeant/data-shield-spring-boot-starter/ -->
<dependency>
    <groupId>com.github.homeant</groupId>
    <artifactId>data-shield-spring-boot-starter</artifactId>
    <version>1.0-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.homeant/data-shield-spring-boot-starter/
implementation 'com.github.homeant:data-shield-spring-boot-starter:1.0-RELEASE'
// https://jarcasting.com/artifacts/com.github.homeant/data-shield-spring-boot-starter/
implementation ("com.github.homeant:data-shield-spring-boot-starter:1.0-RELEASE")
'com.github.homeant:data-shield-spring-boot-starter:jar:1.0-RELEASE'
<dependency org="com.github.homeant" name="data-shield-spring-boot-starter" rev="1.0-RELEASE">
  <artifact name="data-shield-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.homeant', module='data-shield-spring-boot-starter', version='1.0-RELEASE')
)
libraryDependencies += "com.github.homeant" % "data-shield-spring-boot-starter" % "1.0-RELEASE"
[com.github.homeant/data-shield-spring-boot-starter "1.0-RELEASE"]

Dependencies

compile (5)

Group / Artifact Type Version
com.github.homeant : data-shield-core jar 1.0-RELEASE
com.github.pagehelper : pagehelper-spring-boot-starter jar 1.2.13
org.springframework.boot : spring-boot-starter jar
org.mybatis.spring.boot : mybatis-spring-boot-starter jar 2.1.2
org.projectlombok : lombok jar

runtime (1)

Group / Artifact Type Version
mysql : mysql-connector-java jar 8.0.16

test (3)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar
org.springframework.boot : spring-boot-starter-test jar
org.testng : testng jar 7.0.0

Project Modules

There are no modules declared in this project.

data-shield

针对mybatis对业务敏感数据进行加密,为企业数据保驾护航

2021-04-03 16:23:16.604 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : ==>  Preparing: insert into t_user (username,password) values ( ?, ?) 
2021-04-03 16:23:16.629 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : ==> Parameters: tom(String), L0wfhbKDAELRnj03GtjKoQ==(String)
2021-04-03 16:23:16.651 DEBUG 3020 --- [           main] c.g.h.d.shield.mapper.UserMapper.insert  : <==    Updates: 1
2021-04-03 16:23:16.675 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : ==>  Preparing: select id,username,password from t_user where id = ? 
2021-04-03 16:23:16.675 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : ==> Parameters: 75(Integer)
2021-04-03 16:23:23.313 DEBUG 3020 --- [           main] c.g.h.d.s.mapper.UserMapper.selectOn     : <==      Total: 1
2021-04-03 16:23:26.166 DEBUG 3020 --- [           main] com.github.homeant.data.shield.DataTest  : user:User(id=75, username=tom, password=p@ssw0rd1234567)
mysql> select * from t_user;
+----+----------+--------------------------+
| id | username | password                 |
+----+----------+--------------------------+
| 74 | tom      | L0wfhbKDAELRnj03GtjKoQ== |
| 75 | tom      | L0wfhbKDAELRnj03GtjKoQ== |
+----+----------+--------------------------+
2 rows in set (0.03 sec)

pom.xml配置

<dependency>
   <groupId>com.github.homeant</groupId>
   <artifactId>data-shield</artifactId>
   <version>1.0-BATE</version>
</dependency>

yaml配置

app:
  data:
    shield:
      enable: true
      strategy: aes #支持AES/DES模式 
      key: AD42F6697B035B7580E4FEF93BE20BAD

业务字段配置

为需要处理的业务字段添加@TableField注解,只支持String类型

encrypt: 修改过程是否需要加密,默认为false

decode: 查询过程是否需要解密,默认为false

asserts: decode为true时,针对某些数据(历史数据)提供断言,默认值DefaultAssert.class(encrypt=true,decode=true)

@Data
public class User {
    private Integer id;

    private String username;

    @TableField(encrypt = true,decode = true,assertion=Base64Assert.class)
    private String phone;
}

更新日志

2020-05-17

  1. data-shield问世,针对mybatis对业务敏感数据进行加密,包含queryupdate操作;加密模式有AESDES
  2. 新增DataShieldService可单独对业务对象进行加解密
  3. 新增DataShieldHelper可对查询结果进行打码操作

2021-04-03

  1. 添加mybatisCursor查询
  2. 修改query模式不污染原始查询对象

Versions

Version
1.0-RELEASE
1.0-BATE