Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xiaohaoo/encrypt-env-spring-boot-starter
spring boot中对配置信息进行脱敏处理
https://github.com/xiaohaoo/encrypt-env-spring-boot-starter
gradle java spring-boot spring-boot-starter spring-framework
Last synced: 23 days ago
JSON representation
spring boot中对配置信息进行脱敏处理
- Host: GitHub
- URL: https://github.com/xiaohaoo/encrypt-env-spring-boot-starter
- Owner: xiaohaoo
- License: agpl-3.0
- Created: 2022-01-18T13:45:27.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-27T07:58:43.000Z (over 2 years ago)
- Last Synced: 2024-10-01T16:18:40.732Z (about 1 month ago)
- Topics: gradle, java, spring-boot, spring-boot-starter, spring-framework
- Language: Java
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# encrypt-env-spring-boot-starter
# 使用场景
在Spring Boot中,配置参数使用明文的方式造成敏感信息泄露,例如:
```yml
spring:
datasource:
username: admin
password: admin
url: jdbc:mysql://127.0.0.1:3306
```现在,可以使用encrypt-env-spring-boot-starter可以对配置信息进行脱敏处理,避免了因为不安全的因素将敏感数据泄露。遵循spring-boot-starter的通用starter配置方式,开箱即用。
```yml
spring:
datasource:
username: enc:twGrVRJ60ACdcY0JFP/gbQ==
# or username: "{enc:twGrVRJ60ACdcY0JFP/gbQ==}"
password: enc:KsaeJD9ahUNJtR8yR8koJw==
# or password: "{enc:KsaeJD9ahUNJtR8yR8koJw==}"
url: enc:fas0AsdsfafJFP/adaewff
# or url: "abc{enc:fas0AsdsfafJFP/adaewff}cba"
```# 使用方式
1. 引入
```groovy
implementation 'com.xiaohaoo:encrypt-env-spring-boot-starter:1.1.0'
``````xml
com.xiaohaoo
encrypt-env-spring-boot-starter
1.1.0```
2. 配置
对配置文件中的敏感数据进行加密后添加前缀 **enc:** 或者使用 **{enc:密文}** 即可。
```yml
spring:
datasource:
username: enc:twGrVRJ60ACdcY0JFP/gbQ==
# or username: "{enc:twGrVRJ60ACdcY0JFP/gbQ==}"
password: enc:KsaeJD9ahUNJtR8yR8koJw==
# or password: "{enc:KsaeJD9ahUNJtR8yR8koJw==}"
url: enc:fas0AsdsfafJFP/adaewff
# or url: "abc{enc:fas0AsdsfafJFP/adaewff}cba"
```3. 获取加密字符串
```java
public class EncryptEnvApplicationTests {@Test
void encrypt() {
// 对称加密秘钥
SecretHandler aesSecretResolve = new AesSecretHandler("xiaohaoo");
// 要加密的字符串
System.out.println(aesSecretResolve.encrypt("spring boot"));
}
}
```# 加密方法
计划支持:
- [x] AES
- [ ] DES
- [ ] RSA