You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/11/05 13:45:28 UTC
[incubator-streampark] branch dev updated: [Feature] Add sensitivity option when creating variable (#1960)
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 9b324cbdf [Feature] Add sensitivity option when creating variable (#1960)
9b324cbdf is described below
commit 9b324cbdfccdfdf065a50ff919fa773bb182013a
Author: macksonmu <ma...@gmail.com>
AuthorDate: Sat Nov 5 21:45:22 2022 +0800
[Feature] Add sensitivity option when creating variable (#1960)
* [Feature] Add sensitivity option when creating variable #1958
---
.../system/variable/components/VariableDrawer.vue | 20 +++++++++++++++++++
.../src/assembly/script/data/mysql-data.sql | 1 +
.../src/assembly/script/data/pgsql-data.sql | 1 +
.../src/assembly/script/schema/mysql-schema.sql | 1 +
.../src/assembly/script/schema/pgsql-schema.sql | 2 ++
.../src/assembly/script/upgrade/mysql/1.2.4.sql | 2 ++
.../core/controller/VariableController.java | 23 +++++++++++++++++-----
.../streampark/console/core/entity/Variable.java | 10 ++++++++++
.../src/main/resources/db/data-h2.sql | 1 +
.../src/main/resources/db/schema-h2.sql | 1 +
.../main/resources/mapper/core/VariableMapper.xml | 1 +
11 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/streampark-console/streampark-console-newui/src/views/system/variable/components/VariableDrawer.vue b/streampark-console/streampark-console-newui/src/views/system/variable/components/VariableDrawer.vue
index 96b77de1c..73333cbfa 100644
--- a/streampark-console/streampark-console-newui/src/views/system/variable/components/VariableDrawer.vue
+++ b/streampark-console/streampark-console-newui/src/views/system/variable/components/VariableDrawer.vue
@@ -41,6 +41,7 @@
fetchCheckVariableCode,
fetchUpdateVariable,
} from '/@/api/system/variable';
+ import { h } from 'vue';
const emit = defineEmits(['success', 'register']);
@@ -114,6 +115,17 @@
componentProps: { rows: 4 },
rules: [{ max: 100, message: t('system.variable.form.descriptionMessage') }],
},
+ {
+ field: 'desensitization',
+ label: 'Desensitization',
+ component: 'Switch',
+ componentProps: {
+ checkedChildren: 'ON',
+ unCheckedChildren: 'OFF',
+ },
+ defaultValue: false,
+ afterItem: h('span', { class: 'conf-switch' }, 'Whether desensitization is required, e.g: desensitization of sensitive data such as passwords, if enable variable value will be displayed as ********'),
+ }
];
});
@@ -161,3 +173,11 @@
}
}
</script>
+
+<style lang="less">
+ .conf-switch {
+ display: inline-block;
+ margin-top: 10px;
+ color: darkgrey;
+ }
+</style>
diff --git a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
index 8886a88e0..b4ec1ea27 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
@@ -109,6 +109,7 @@ insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 'variable:add',
insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 'variable:update', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 'variable:delete', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', '/system/variable/depend_apps', 'system/variable/DependApps', 'variable:dependApps', '', '0', 0, NULL, now(), now());
+insert into `t_menu` VALUES (100059, 100054, 'Show Original', NULL, NULL, 'variable:showOriginal', NULL, '1', 1, NULL, now(), now());
-- ----------------------------
-- Records of t_role
diff --git a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
index 2c6c0826c..94c4a8f42 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
@@ -105,6 +105,7 @@ insert into "public"."t_menu" VALUES (100055, 100054, 'add', NULL, NULL, 'variab
insert into "public"."t_menu" VALUES (100056, 100054, 'update', NULL, NULL, 'variable:update', NULL, '1', 1, NULL, now(), now());
insert into "public"."t_menu" VALUES (100057, 100054, 'delete', NULL, NULL, 'variable:delete', NULL, '1', 1, NULL, now(), now());
insert into "public"."t_menu" VALUES (100058, 100013, 'Depend Apps', '/system/variable/depend_apps', 'system/variable/DependApps', 'variable:dependApps', '', '0', 0, NULL, now(), now());
+insert into "public"."t_menu" VALUES (100059, 100054, 'Show Original', NULL, NULL, 'variable:showOriginal', NULL, '1', 1, NULL, now(), now());
-- ----------------------------
-- Records of t_role
diff --git a/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql b/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
index 9a3b9e0a4..1c154de44 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/schema/mysql-schema.sql
@@ -330,6 +330,7 @@ create table `t_variable` (
`description` text collate utf8mb4_general_ci default null comment 'More detailed description of variables',
`creator_id` bigint collate utf8mb4_general_ci not null comment 'user id of creator',
`team_id` bigint collate utf8mb4_general_ci not null comment 'team id',
+ `desensitization` tinyint not null default 0 comment '0 is no desensitization, 1 is desensitization, if set to desensitization, it will be replaced by * when displayed',
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
primary key (`id`) using btree,
diff --git a/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql b/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
index 898edc03f..2f8b3ddda 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/schema/pgsql-schema.sql
@@ -617,6 +617,7 @@ create table "public"."t_variable" (
"description" text collate "pg_catalog"."default" default null,
"creator_id" int8 collate "pg_catalog"."default" not null,
"team_id" int8 collate "pg_catalog"."default" not null,
+ "desensitization" boolean not null default false,
"create_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
"modify_time" timestamp(6) not null default timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
)
@@ -627,6 +628,7 @@ comment on column "public"."t_variable"."variable_value" is 'The specific value
comment on column "public"."t_variable"."description" is 'More detailed description of variables';
comment on column "public"."t_variable"."creator_id" is 'user id of creator';
comment on column "public"."t_variable"."team_id" is 'team id';
+comment on column "public"."t_variable"."desensitization" is '0 is no desensitization, 1 is desensitization, if set to desensitization, it will be replaced by * when displayed';
comment on column "public"."t_variable"."create_time" is 'creation time';
comment on column "public"."t_variable"."modify_time" is 'modify time';
diff --git a/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql b/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
index 45012f18c..11d10be06 100644
--- a/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
+++ b/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
@@ -134,6 +134,7 @@ insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 'variable:add',
insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 'variable:update', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 'variable:delete', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', '/system/variable/depend_apps', 'system/variable/DependApps', 'variable:dependApps', '', '0', 0, NULL, now(), now());
+insert into `t_menu` VALUES (100059, 100054, 'Show Original', NULL, NULL, 'variable:showOriginal', NULL, '1', 1, NULL, now(), now());
update `t_menu` set order_num=4 where menu_id=100019;
update `t_menu` set order_num=5 where menu_id=100034;
@@ -253,6 +254,7 @@ create table `t_variable` (
`description` text collate utf8mb4_general_ci default null comment 'More detailed description of variables',
`creator_id` bigint collate utf8mb4_general_ci not null comment 'user id of creator',
`team_id` bigint collate utf8mb4_general_ci not null comment 'team id',
+ `desensitization` tinyint not null default 0 comment '0 is no desensitization, 1 is desensitization, if set to desensitization, it will be replaced by * when displayed',
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
primary key (`id`) using btree,
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
index 92dd3fb77..d4a3fdbac 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
@@ -59,8 +59,11 @@ public class VariableController {
@PostMapping("page")
@RequiresPermissions("variable:view")
public RestResponse page(RestRequest restRequest, Variable variable) {
- IPage<Variable> variableList = variableService.page(variable, restRequest);
- return RestResponse.success(variableList);
+ IPage<Variable> page = variableService.page(variable, restRequest);
+ for (Variable v : page.getRecords()) {
+ v.dataMasking();
+ }
+ return RestResponse.success(page);
}
/**
@@ -72,6 +75,9 @@ public class VariableController {
@PostMapping("list")
public RestResponse variableList(@RequestParam Long teamId, String keyword) {
List<Variable> variableList = variableService.findByTeamId(teamId, keyword);
+ for (Variable v : variableList) {
+ v.dataMasking();
+ }
return RestResponse.success(variableList);
}
@@ -84,14 +90,14 @@ public class VariableController {
@PostMapping("post")
@RequiresPermissions("variable:add")
- public RestResponse addVariable(@Valid Variable variable) throws Exception {
+ public RestResponse addVariable(@Valid Variable variable) {
this.variableService.createVariable(variable);
return RestResponse.success();
}
@PutMapping("update")
@RequiresPermissions("variable:update")
- public RestResponse updateVariable(@Valid Variable variable) throws Exception {
+ public RestResponse updateVariable(@Valid Variable variable) {
if (variable.getId() == null) {
throw new ApiAlertException("Sorry, the variable id cannot be null.");
}
@@ -106,9 +112,16 @@ public class VariableController {
return RestResponse.success();
}
+ @PostMapping("showOriginal")
+ @RequiresPermissions("variable:showOriginal")
+ public RestResponse showOriginal(@RequestParam Long id) {
+ Variable v = this.variableService.getById(id);
+ return RestResponse.success(v);
+ }
+
@DeleteMapping("delete")
@RequiresPermissions("variable:delete")
- public RestResponse deleteVariable(@Valid Variable variable) throws Exception {
+ public RestResponse deleteVariable(@Valid Variable variable) {
this.variableService.deleteVariable(variable);
return RestResponse.success();
}
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java
index b115de667..c41aa5134 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java
@@ -17,6 +17,8 @@
package org.apache.streampark.console.core.entity;
+import org.apache.streampark.common.conf.ConfigConst;
+
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -60,6 +62,8 @@ public class Variable implements Serializable {
@NotNull(message = "{required}")
private Long teamId;
+ private Boolean desensitization;
+
private transient Date createTime;
private transient Date modifyTime;
@@ -67,4 +71,10 @@ public class Variable implements Serializable {
private transient String sortField;
private transient String sortOrder;
+
+ public void dataMasking() {
+ if (desensitization) {
+ this.setVariableValue(ConfigConst.DEFAULT_DATAMASK_STRING());
+ }
+ }
}
diff --git a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
index 7c657f6a5..2a0a781e7 100644
--- a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
+++ b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
@@ -104,6 +104,7 @@ insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 'variable:add',
insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 'variable:update', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 'variable:delete', NULL, '1', 1, NULL, now(), now());
insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', '/system/variable/depend_apps', 'system/variable/DependApps', 'variable:dependApps', '', '0', 0, NULL, now(), now());
+insert into `t_menu` VALUES (100059, 100054, 'Show Original', NULL, NULL, 'variable:showOriginal', NULL, '1', 1, NULL, now(), now());
-- ----------------------------
-- Records of t_role
diff --git a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
index 1265851e5..1be42d1f9 100644
--- a/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
+++ b/streampark-console/streampark-console-service/src/main/resources/db/schema-h2.sql
@@ -292,6 +292,7 @@ create table if not exists `t_variable` (
`description` text default null comment 'More detailed description of variables, only for display, not involved in program logic',
`creator_id` bigint not null comment 'user id of creator',
`team_id` bigint not null comment 'team id',
+ `desensitization` tinyint not null default 0 comment '0 is no desensitization, 1 is desensitization, if set to desensitization, it will be replaced by * when displayed',
`create_time` datetime not null default current_timestamp comment 'create time',
`modify_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
primary key (`id`),
diff --git a/streampark-console/streampark-console-service/src/main/resources/mapper/core/VariableMapper.xml b/streampark-console/streampark-console-service/src/main/resources/mapper/core/VariableMapper.xml
index 8e7172555..c9b09e44f 100644
--- a/streampark-console/streampark-console-service/src/main/resources/mapper/core/VariableMapper.xml
+++ b/streampark-console/streampark-console-service/src/main/resources/mapper/core/VariableMapper.xml
@@ -25,6 +25,7 @@
<result column="variable_value" jdbcType="VARCHAR" property="variableValue"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
+ <result column="desensitization" jdbcType="BOOLEAN" property="desensitization"/>
<result column="team_id" jdbcType="BIGINT" property="teamId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>