mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 20:15:49 +08:00
Compare commits
4 Commits
v3.4.0
...
feature/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1e858e998 | ||
|
|
232f06e5c2 | ||
|
|
fcf0a08e0a | ||
|
|
68839a6725 |
@@ -146,7 +146,7 @@ PS: 提问请尽量把问题一次性描述清楚,并告知环境信息情况
|
|||||||
|
|
||||||
**`2、微信群`**
|
**`2、微信群`**
|
||||||
|
|
||||||
微信加群:添加`PenceXie` 、`szzdzhp001`的微信号备注KnowStreaming加群。
|
微信加群:添加`PenceXie` 的微信号备注KnowStreaming加群。
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
加群之前有劳点一下 star,一个小小的 star 是对KnowStreaming作者们努力建设社区的动力。
|
加群之前有劳点一下 star,一个小小的 star 是对KnowStreaming作者们努力建设社区的动力。
|
||||||
|
|||||||
115
docs/dev_guide/MYSQL密码加密手册.md
Normal file
115
docs/dev_guide/MYSQL密码加密手册.md
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
## YML文件MYSQL密码加密存储手册
|
||||||
|
|
||||||
|
### 1、本地部署加密
|
||||||
|
|
||||||
|
**第一步:生成密文**
|
||||||
|
|
||||||
|
在本地仓库中找到jasypt-1.9.3.jar,默认在org/jasypt/jasypt/1.9.3中,使用`java -cp`生成密文。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
java -cp jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input=mysql密码 password=加密的salt algorithm=PBEWithMD5AndDES
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 得到密文
|
||||||
|
DYbVDLg5D0WRcJSCUGWjiw==
|
||||||
|
```
|
||||||
|
|
||||||
|
**第二步:配置jasypt**
|
||||||
|
|
||||||
|
在YML文件中配置jasypt,例如
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jasypt:
|
||||||
|
encryptor:
|
||||||
|
algorithm: PBEWithMD5AndDES
|
||||||
|
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||||
|
```
|
||||||
|
|
||||||
|
**第三步:配置密文**
|
||||||
|
|
||||||
|
使用密文替换YML文件中的明文密码为ENC(密文),例如[application.yml](https://github.com/didi/KnowStreaming/blob/master/km-rest/src/main/resources/application.yml)中MYSQL密码。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
know-streaming:
|
||||||
|
username: root
|
||||||
|
password: ENC(DYbVDLg5D0WRcJSCUGWjiw==)
|
||||||
|
```
|
||||||
|
|
||||||
|
**第四步:配置加密的salt(选择其一)**
|
||||||
|
|
||||||
|
- 配置在YML文件中(不推荐)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jasypt:
|
||||||
|
encryptor:
|
||||||
|
password: salt
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置程序启动时的命令行参数
|
||||||
|
|
||||||
|
```bash
|
||||||
|
java -jar xxx.jar --jasypt.encryptor.password=salt
|
||||||
|
```
|
||||||
|
|
||||||
|
- 配置程序启动时的环境变量
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export JASYPT_PASSWORD=salt
|
||||||
|
java -jar xxx.jar --jasypt.encryptor.password=${JASYPT_PASSWORD}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2、容器部署加密
|
||||||
|
|
||||||
|
利用docker swarm 提供的 secret 机制加密存储密码,使用docker swarm来管理密码。
|
||||||
|
|
||||||
|
### 2.1、secret加密存储
|
||||||
|
|
||||||
|
**第一步:初始化docker swarm**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker swarm init
|
||||||
|
```
|
||||||
|
|
||||||
|
**第二步:创建密钥**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "admin2022_" | docker secret create mysql_password -
|
||||||
|
|
||||||
|
# 输出密钥
|
||||||
|
f964wi4gg946hu78quxsh2ge9
|
||||||
|
```
|
||||||
|
|
||||||
|
**第三步:使用密钥**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# mysql用户密码
|
||||||
|
SERVER_MYSQL_USER: root
|
||||||
|
SERVER_MYSQL_PASSWORD: mysql_password
|
||||||
|
|
||||||
|
knowstreaming-mysql:
|
||||||
|
# root 用户密码
|
||||||
|
MYSQL_ROOT_PASSWORD: mysql_password
|
||||||
|
secrets:
|
||||||
|
mysql_password:
|
||||||
|
external: true
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.2、使用密钥文件加密
|
||||||
|
|
||||||
|
**第一步:创建密钥**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "admin2022_" > password
|
||||||
|
```
|
||||||
|
|
||||||
|
**第二步:使用密钥**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# mysql用户密码
|
||||||
|
SERVER_MYSQL_USER: root
|
||||||
|
SERVER_MYSQL_PASSWORD: mysql_password
|
||||||
|
secrets:
|
||||||
|
mysql_password:
|
||||||
|
file: ./password
|
||||||
|
```
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<nodeVersion>v12.22.12</nodeVersion>
|
<nodeVersion>v12.22.12</nodeVersion>
|
||||||
<npmVersion>6.14.16</npmVersion>
|
<npmVersion>6.14.16</npmVersion>
|
||||||
<nodeDownloadRoot>https://npm.taobao.org/mirrors/node/</nodeDownloadRoot>
|
<nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
|
||||||
<npmDownloadRoot>https://registry.npm.taobao.org/npm/-/</npmDownloadRoot>
|
<npmDownloadRoot>https://registry.npmmirror.com/npm/-/</npmDownloadRoot>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import scala.jdk.javaapi.CollectionConverters;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.xiaojukeji.know.streaming.km.common.enums.version.VersionEnum.*;
|
import static com.xiaojukeji.know.streaming.km.common.enums.version.VersionEnum.*;
|
||||||
|
|
||||||
@@ -154,9 +155,11 @@ public class BrokerConfigServiceImpl extends BaseKafkaVersionControlService impl
|
|||||||
if (propertiesResult.failed()) {
|
if (propertiesResult.failed()) {
|
||||||
return Result.buildFromIgnoreData(propertiesResult);
|
return Result.buildFromIgnoreData(propertiesResult);
|
||||||
}
|
}
|
||||||
|
List<String> configKeyList = propertiesResult.getData().keySet().stream().map(Object::toString).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
return Result.buildSuc(KafkaConfigConverter.convert2KafkaBrokerConfigDetailList(
|
return Result.buildSuc(KafkaConfigConverter.convert2KafkaBrokerConfigDetailList(
|
||||||
new ArrayList<>(),
|
configKeyList,
|
||||||
propertiesResult.getData()
|
propertiesResult.getData()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,12 @@
|
|||||||
<version>${springboot.version}</version>
|
<version>${springboot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--testcontainers-->
|
<!--testcontainers-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testcontainers</groupId>
|
<groupId>org.testcontainers</groupId>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.xiaojukeji.know.streaming.km.common.constant.ApiPrefix;
|
|||||||
import com.xiaojukeji.know.streaming.km.common.utils.GitPropUtil;
|
import com.xiaojukeji.know.streaming.km.common.utils.GitPropUtil;
|
||||||
import com.xiaojukeji.know.streaming.km.rest.interceptor.PermissionInterceptor;
|
import com.xiaojukeji.know.streaming.km.rest.interceptor.PermissionInterceptor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
import org.springframework.web.servlet.config.annotation.*;
|
||||||
@@ -24,6 +25,9 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
private static final String FE_INDEX_PAGE_HTML = "layout/index";
|
private static final String FE_INDEX_PAGE_HTML = "layout/index";
|
||||||
|
|
||||||
|
@Value(value = "${swagger.enabled:true}")
|
||||||
|
private Boolean swaggerEnabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
// FE-首页
|
// FE-首页
|
||||||
@@ -69,7 +73,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
RequestHandlerSelectors.basePackage("com.didiglobal.logi.security.controller")))
|
RequestHandlerSelectors.basePackage("com.didiglobal.logi.security.controller")))
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build()
|
.build()
|
||||||
.enable(true);
|
.enable(swaggerEnabled != null && swaggerEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiInfo apiInfo() {
|
private ApiInfo apiInfo() {
|
||||||
|
|||||||
@@ -116,3 +116,6 @@ management:
|
|||||||
enabled: true
|
enabled: true
|
||||||
tags:
|
tags:
|
||||||
application: know-streaming
|
application: know-streaming
|
||||||
|
|
||||||
|
swagger:
|
||||||
|
enabled: true
|
||||||
|
|||||||
Reference in New Issue
Block a user