Skip to content

Commit 63c52de

Browse files
litiliulitiliu
and
litiliu
authored
[config][doc]add sensitive columns and enhance the doc (#8523)
Co-authored-by: litiliu <[email protected]>
1 parent 2aaee5d commit 63c52de

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

Diff for: docs/en/connector-v2/Config-Encryption-Decryption.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Base64 encryption support encrypt the following parameters:
1212
- username
1313
- password
1414
- auth
15+
- token
16+
- access_key
17+
- secret_key
1518

1619
Next, I'll show how to quickly use SeaTunnel's own `base64` encryption:
1720

@@ -130,13 +133,14 @@ If you want to customize the encryption method and the configuration of the encr
130133

131134
1. Create a java maven project
132135

133-
2. Add `seatunnel-api` module in dependencies like the following shown:
136+
2. Add `seatunnel-api` module with the provided scope in dependencies like the following shown:
134137

135138
```xml
136139
<dependency>
137140
<groupId>org.apache.seatunnel</groupId>
138141
<artifactId>seatunnel-api</artifactId>
139142
<version>${seatunnel.version}</version>
143+
<scope>provided</scope>
140144
</dependency>
141145
```
142146
3. Create a new class and implement interface `ConfigShade`, this interface has the following methods:
@@ -174,7 +178,8 @@ If you want to customize the encryption method and the configuration of the encr
174178
}
175179
}
176180
```
177-
4. Add `org.apache.seatunnel.api.configuration.ConfigShade` in `resources/META-INF/services`
181+
4. Create a file named `org.apache.seatunnel.api.configuration.ConfigShade` in `resources/META-INF/services`, the file content should be the fully qualified class name of the class that you defined in step 3.
182+
178183
5. Package it to jar and add jar to `${SEATUNNEL_HOME}/lib`
179184
6. Change the option `shade.identifier` to the value that you defined in `ConfigShade#getIdentifier`of you config file, please enjoy it \^_\^
180185

Diff for: docs/zh/connector-v2/Config-Encryption-Decryption.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Base64编码支持加密以下参数:
1212
- username
1313
- password
1414
- auth
15+
- token
16+
- access_key
17+
- secret_key
1518

1619
接下来,将展示如何快速使用 SeaTunnel 自带的 `base64` 加密功能:
1720

@@ -138,6 +141,7 @@ Base64编码支持加密以下参数:
138141
<groupId>org.apache.seatunnel</groupId>
139142
<artifactId>seatunnel-api</artifactId>
140143
<version>${seatunnel.version}</version>
144+
<scope>provided</scope>
141145
</dependency>
142146
```
143147
3. 创建一个 java 类并实现 `ConfigShade` 接口,该接口包含以下方法:
@@ -175,7 +179,7 @@ Base64编码支持加密以下参数:
175179
}
176180
}
177181
```
178-
4.`resources/META-INF/services` 目录下添加 `org.apache.seatunnel.api.configuration.ConfigShade`
182+
4.`resources/META-INF/services` 目录下创建名为 `org.apache.seatunnel.api.configuration.ConfigShade`的文件, 文件内容是您在步骤 3 中定义的类的完全限定类名。
179183
5. 将其打成 jar 包, 并添加到 `${SEATUNNEL_HOME}/lib` 目录下。
180184
6. 将选项 `shade.identifier` 的值更改为上面定义在配置文件中的 `ConfigShade#getIdentifier` 的值。
181185

Diff for: seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/utils/ConfigShadeUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public final class ConfigShadeUtils {
4848
private static final String SHADE_IDENTIFIER_OPTION = "shade.identifier";
4949

5050
public static final String[] DEFAULT_SENSITIVE_KEYWORDS =
51-
new String[] {"password", "username", "auth", "token"};
51+
new String[] {"password", "username", "auth", "token", "access_key", "secret_key"};
5252

5353
private static final Map<String, ConfigShade> CONFIG_SHADES = new HashMap<>();
5454

Diff for: seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/utils/ConfigShadeTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public class ConfigShadeTest {
5151

5252
private static final String PASSWORD = "seatunnel_password";
5353

54+
private static final String ACCESS_KEY = "access_key";
55+
private static final String SECRET_KEY = "secret_key";
56+
5457
@Test
5558
public void testParseConfig() throws URISyntaxException {
5659
URL resource = ConfigShadeTest.class.getResource("/config.shade.conf");
@@ -71,6 +74,10 @@ public void testParseConfig() throws URISyntaxException {
7174
config.getConfigList("source").get(0).getString("username"), USERNAME);
7275
Assertions.assertEquals(
7376
config.getConfigList("source").get(0).getString("password"), PASSWORD);
77+
Assertions.assertEquals(
78+
config.getConfigList("source").get(0).getString("access_key"), ACCESS_KEY);
79+
Assertions.assertEquals(
80+
config.getConfigList("source").get(0).getString("secret_key"), SECRET_KEY);
7481
}
7582

7683
@Test
@@ -89,6 +96,10 @@ public void testUsePrivacyHandlerHocon() throws URISyntaxException {
8996
config.getConfigList("source").get(0).getString("username"), "******");
9097
Assertions.assertEquals(
9198
config.getConfigList("source").get(0).getString("password"), "******");
99+
Assertions.assertEquals(
100+
config.getConfigList("source").get(0).getString("access_key"), "******");
101+
Assertions.assertEquals(
102+
config.getConfigList("source").get(0).getString("secret_key"), "******");
92103
String conf = ConfigBuilder.mapToString(config.root().unwrapped());
93104
Assertions.assertTrue(conf.contains("\"password\" : \"******\""));
94105
}

Diff for: seatunnel-core/seatunnel-core-starter/src/test/resources/config.shade.conf

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ source {
3939
database-name = "inventory_vwyw0n"
4040
table-name = "products"
4141
base-url = "jdbc:mysql://localhost:56725"
42+
43+
# test properties
44+
access_key = "YWNjZXNzX2tleQ=="
45+
secret_key = "c2VjcmV0X2tleQ=="
4246
}
4347
}
4448

0 commit comments

Comments
 (0)