Skip to content

Commit c27c1a2

Browse files
committed
feat:support partial configuration encrypt.
1 parent 0234c19 commit c27c1a2

File tree

40 files changed

+988
-243
lines changed

40 files changed

+988
-243
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: License checker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release*
8+
pull_request:
9+
branches:
10+
- main
11+
- release*
12+
jobs:
13+
check-license:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout codes
17+
uses: actions/checkout@v4
18+
- name: Check License Header
19+
uses: apache/[email protected]

.licenserc.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
header:
2+
license:
3+
content: |
4+
Tencent is pleased to support the open source community by making Polaris available.
5+
6+
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
7+
8+
Licensed under the BSD 3-Clause License (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
https://opensource.org/licenses/BSD-3-Clause
13+
14+
Unless required by applicable law or agreed to in writing, software distributed
15+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations under the License.
18+
paths:
19+
- "**/tencent/**"
20+
language:
21+
Java:
22+
extensions:
23+
- ".java"

polaris-assembly/polaris-assembly-client/src/main/java/com/tencent/polaris/assembly/client/flow/DefaultAssemblyFlow.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@
1717

1818
package com.tencent.polaris.assembly.client.flow;
1919

20-
import java.util.Collections;
21-
import java.util.List;
22-
2320
import com.tencent.polaris.api.config.Configuration;
2421
import com.tencent.polaris.api.config.global.FlowConfig;
2522
import com.tencent.polaris.api.plugin.compose.Extensions;
2623
import com.tencent.polaris.api.plugin.loadbalance.LoadBalancer;
2724
import com.tencent.polaris.api.plugin.route.RouteInfo;
2825
import com.tencent.polaris.api.plugin.stat.TraceReporter;
29-
import com.tencent.polaris.api.pojo.Instance;
30-
import com.tencent.polaris.api.pojo.ServiceEventKey;
31-
import com.tencent.polaris.api.pojo.ServiceInfo;
32-
import com.tencent.polaris.api.pojo.ServiceInstances;
33-
import com.tencent.polaris.api.pojo.ServiceKey;
34-
import com.tencent.polaris.api.pojo.SourceService;
26+
import com.tencent.polaris.api.pojo.*;
3527
import com.tencent.polaris.api.rpc.RequestBaseEntity;
3628
import com.tencent.polaris.api.rpc.ServiceCallResult;
3729
import com.tencent.polaris.api.utils.CollectionUtils;
@@ -46,6 +38,9 @@
4638
import com.tencent.polaris.client.flow.ResourcesResponse;
4739
import com.tencent.polaris.discovery.client.flow.CommonInstancesRequest;
4840

41+
import java.util.Collections;
42+
import java.util.List;
43+
4944
public class DefaultAssemblyFlow implements AssemblyFlow {
5045

5146
private SDKContext sdkContext;
@@ -191,18 +186,18 @@ public void updateTraceAttributes(TraceAttributes traceAttributes) {
191186
return;
192187
}
193188
TraceReporter traceReporter = extensions.getTraceReporter();
194-
if (null == traceReporter) {
189+
if (null == traceReporter || !traceReporter.isEnabled()) {
195190
return;
196191
}
197192
switch (traceAttributes.getAttributeLocation()) {
198-
case SPAN:
199-
traceReporter.setSpanAttributes(traceAttributes.getAttributes());
200-
break;
201-
case BAGGAGE:
202-
traceReporter.setBaggageAttributes(traceAttributes.getAttributes());
203-
break;
204-
default:
205-
break;
193+
case SPAN:
194+
traceReporter.setSpanAttributes(traceAttributes.getAttributes());
195+
break;
196+
case BAGGAGE:
197+
traceReporter.setBaggageAttributes(traceAttributes.getAttributes());
198+
break;
199+
default:
200+
break;
206201
}
207202
}
208203

polaris-assembly/polaris-assembly-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
<artifactId>event-logger</artifactId>
8585
<version>${project.version}</version>
8686
</dependency>
87+
<dependency>
88+
<groupId>com.tencent.polaris</groupId>
89+
<artifactId>event-tsf</artifactId>
90+
<version>${project.version}</version>
91+
</dependency>
8792

8893
<!--测试依赖插件-->
8994
<dependency>

polaris-auth/polaris-auth-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<artifactId>polaris-auth-client</artifactId>
2121
<version>${project.version}</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>com.tencent.polaris</groupId>
25+
<artifactId>auth-block-allow-list</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
2328
<dependency>
2429
<groupId>com.tencent.polaris</groupId>
2530
<artifactId>polaris-client</artifactId>

polaris-circuitbreaker/polaris-circuitbreaker-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
<artifactId>event-logger</artifactId>
107107
<version>${project.version}</version>
108108
</dependency>
109+
<dependency>
110+
<groupId>com.tencent.polaris</groupId>
111+
<artifactId>event-tsf</artifactId>
112+
<version>${project.version}</version>
113+
</dependency>
109114

110115
<!--健康检查插件-->
111116
<dependency>

polaris-common/polaris-client/src/main/java/com/tencent/polaris/client/flow/BaseFlow.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private static boolean loadLocalResources(ServiceEventKey svcEventKey, Resources
297297
}
298298

299299
public static Instance processLoadBalance(LoadBalancer loadBalancer, Criteria criteria,
300-
ServiceInstances dstInstances, List<WeightAdjuster> weightAdjusters) throws PolarisException {
300+
ServiceInstances dstInstances, List<WeightAdjuster> weightAdjusters) throws PolarisException {
301301
if (criteria == null) {
302302
criteria = new Criteria();
303303
}
@@ -357,6 +357,9 @@ public static void reportFlowEvent(Extensions extensions, FlowEvent flowEvent) {
357357
}
358358
for (EventReporter eventReporter : eventReporterList) {
359359
try {
360+
if (!eventReporter.isEnabled()) {
361+
continue;
362+
}
360363
if (!eventReporter.reportEvent(flowEvent)) {
361364
LOG.warn("Report event by {} failed. Flow event detail: {}", eventReporter.getName(), flowEvent);
362365
}

polaris-common/polaris-config-default/src/main/resources/conf/default-config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ global:
8686
#描述: 事件上报插件名列表
8787
reporters:
8888
- logger
89+
# 描述:事件上报插件配置
90+
plugin:
91+
# 描述:TSF 事件上报插件配置
92+
tsf:
93+
# 描述:TSF 事件上报开关
94+
enable: false
8995
# 描述:Admin相关的配置
9096
admin:
9197
# 描述:Admin的监听的IP
@@ -286,7 +292,7 @@ consumer:
286292
weightAdjust:
287293
enable: true
288294
chain:
289-
# 开启了服务预热插件,可以支持多个动态权重调整插件同时生效
295+
# 开启了服务预热插件,可以支持多个动态权重调整插件同时生效
290296
# - warmup
291297
# 被调方配置
292298
provider:
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>polaris-common</artifactId>
7+
<groupId>com.tencent.polaris</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>polaris-encrypt</artifactId>
14+
<name>Polaris Common Encrypt</name>
15+
<description>Polaris Common Encrypt JAR</description>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.tencent.polaris</groupId>
20+
<artifactId>polaris-model</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.slf4j</groupId>
25+
<artifactId>slf4j-api</artifactId>
26+
<version>${slf4j.version}</version>
27+
<scope>provided</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.bouncycastle</groupId>
31+
<artifactId>bcpkix-jdk15to18</artifactId>
32+
<version>${bouncycastle.version}</version>
33+
</dependency>
34+
</dependencies>
35+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
18+
package com.tencent.polaris.encrypt;
19+
20+
/**
21+
* TSF 配置加密提供器接口
22+
*
23+
* @author hongweizhu
24+
*/
25+
public abstract class ConfigEncryptProvider {
26+
27+
/**
28+
* 加密
29+
*
30+
* @param content 明文
31+
* @param password 密码
32+
* @return 密文
33+
*/
34+
public abstract String encrypt(String content, String password);
35+
36+
/**
37+
* 解密
38+
*
39+
* @param encryptedContent 密文
40+
* @param password 密码
41+
* @return 明文
42+
*/
43+
public abstract String decrypt(String encryptedContent, String password);
44+
}

0 commit comments

Comments
 (0)