Explorar el Código

[Improvement-11913] Mask password when creating/editing alert instances (#14415)

* [Improvement-11913] Mask password when creating/editing alert instances
c3Vu hace 1 año
padre
commit
50195c46aa

+ 2 - 2
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannelFactory.java

@@ -25,7 +25,6 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
 import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
-import org.apache.dolphinscheduler.spi.params.PasswordParam;
 import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
@@ -136,9 +135,10 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
                         .setRequired(false)
                         .build())
                 .build();
-        PasswordParam passwordParam = PasswordParam
+        InputParam passwordParam = InputParam
                 .newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
                 .setPlaceholder(AlertInputTips.PASSWORD.getMsg())
+                .setType("password")
                 .build();
 
         return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam,

+ 3 - 3
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactory.java

@@ -27,7 +27,6 @@ import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertConstants;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
 import org.apache.dolphinscheduler.alert.api.ShowType;
-import org.apache.dolphinscheduler.spi.params.PasswordParam;
 import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
@@ -97,9 +96,10 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
                 .setPlaceholder(AlertInputTips.USERNAME.getMsg())
                 .build();
 
-        PasswordParam mailPassword =
-                PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
+        InputParam mailPassword =
+                InputParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
                         .setPlaceholder(AlertInputTips.PASSWORD.getMsg())
+                        .setType("password")
                         .build();
 
         RadioParam enableTls = RadioParam

+ 1 - 3
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java

@@ -23,7 +23,6 @@ import org.apache.dolphinscheduler.alert.api.AlertInfo;
 import org.apache.dolphinscheduler.alert.api.AlertResult;
 import org.apache.dolphinscheduler.alert.api.ShowType;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.spi.params.PasswordParam;
 import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
@@ -107,9 +106,8 @@ public class EmailAlertChannelTest {
                 .setValue("dolphinscheduler@126.com")
                 .build();
 
-        PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, "passwd")
+        InputParam mailPassword = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, "passwd")
                 .setPlaceholder("if enable use authentication, you need input password")
-                .setValue("escheduler123")
                 .build();
 
         RadioParam enableTls =

+ 2 - 2
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannelFactory.java

@@ -25,7 +25,6 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
 import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
-import org.apache.dolphinscheduler.spi.params.PasswordParam;
 import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
@@ -85,9 +84,10 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
                         .addValidate(Validate.newBuilder()
                                 .setRequired(false).build())
                         .build();
-        PasswordParam passwordParam = PasswordParam
+        InputParam passwordParam = InputParam
                 .newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
                 .setPlaceholder(AlertInputTips.PASSWORD.getMsg())
+                .setType("password")
                 .build();
 
         return Arrays.asList(webHookParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);

+ 2 - 2
dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramAlertChannelFactory.java

@@ -25,7 +25,6 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
 import org.apache.dolphinscheduler.alert.api.AlertChannel;
 import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
 import org.apache.dolphinscheduler.alert.api.AlertInputTips;
-import org.apache.dolphinscheduler.spi.params.PasswordParam;
 import org.apache.dolphinscheduler.spi.params.base.DataType;
 import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
 import org.apache.dolphinscheduler.spi.params.base.PluginParams;
@@ -131,12 +130,13 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
                                 .build())
                         .build();
 
-        PasswordParam passwordParam = PasswordParam
+        InputParam passwordParam = InputParam
                 .newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PASSWORD, TelegramParamsConstants.TELEGRAM_PASSWORD)
                 .addValidate(Validate.newBuilder()
                         .setRequired(false)
                         .build())
                 .setPlaceholder("if enable use authentication, you need input password")
+                .setType("password")
                 .build();
 
         return Arrays.asList(webHookParam, botTokenParam, chatIdParam, parseMode, isEnableProxy, proxyParam, portParam,

+ 0 - 87
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/PasswordParam.java

@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.spi.params;
-
-import org.apache.dolphinscheduler.spi.params.base.FormType;
-import org.apache.dolphinscheduler.spi.params.base.ParamsProps;
-import org.apache.dolphinscheduler.spi.params.base.PluginParams;
-import org.apache.dolphinscheduler.spi.params.base.Validate;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * password param
- */
-public class PasswordParam extends PluginParams {
-
-    private PasswordParam(Builder builder) {
-        super(builder);
-    }
-
-    public static Builder newBuilder(String name, String title) {
-        return new Builder(name, title);
-    }
-
-    public static class Builder extends PluginParams.Builder {
-
-        public Builder(String name, String title) {
-            super(name, FormType.INPUT, title);
-            ParamsProps paramsProps = new ParamsProps();
-            this.props = paramsProps;
-        }
-
-        public Builder setPlaceholder(String placeholder) {
-            this.props.setPlaceholder(placeholder);
-            return this;
-        }
-
-        public Builder addValidate(Validate validate) {
-            if (this.validateList == null) {
-                this.validateList = new ArrayList<>();
-            }
-            this.validateList.add(validate);
-            return this;
-        }
-
-        public Builder setName(String name) {
-            this.name = name;
-            return this;
-        }
-
-        public Builder setTitle(String title) {
-            this.title = title;
-            return this;
-        }
-
-        public Builder setValue(Object value) {
-            this.value = value;
-            return this;
-        }
-
-        public Builder setValidateList(List<Validate> validateList) {
-            this.validateList = validateList;
-            return this;
-        }
-
-        @Override
-        public PasswordParam build() {
-            return new PasswordParam(this);
-        }
-    }
-}

+ 9 - 4
dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/params/PluginParamsTransferTest.java

@@ -86,8 +86,9 @@ public class PluginParamsTransferTest {
                 .setPlaceholder("if enable use authentication, you need input user")
                 .build();
 
-        PasswordParam mailPassword = new PasswordParam.Builder("field8", "field8")
+        InputParam mailPassword = new InputParam.Builder("field8", "field8")
                 .setPlaceholder("if enable use authentication, you need input password")
+                .setType("password")
                 .build();
 
         RadioParam enableTls = new RadioParam.Builder("field9", "field9")
@@ -160,9 +161,13 @@ public class PluginParamsTransferTest {
                 + "\"validateEvent\":null,\"showPassword\":null,\"placeholder\":\"if enable use authentication, "
                 + "you need input user\",\"size\":\"small\"},\"field\":\"field7\",\"name\":\"field7\","
                 + "\"type\":\"input\",\"title\":\"field7\",\"value\":null,\"validate\":null,\"emit\":null},"
-                + "{\"field\":\"field8\",\"name\":\"field8\",\"props\":{\"disabled\":null,\"placeholder\":"
-                + "\"if enable use authentication, you need input password\",\"size\":\"small\"},\"type\":"
-                + "\"input\",\"title\":\"field8\",\"value\":null,\"validate\":null,\"emit\":null},{\"props\":"
+                + "{\"props\":{\"disabled\":null,\"type\":\"password\",\"maxlength\":null,\"minlength\":null,\""
+                + "clearable\":null,\"prefixIcon\":null,\"suffixIcon\":null,\"rows\":null,\"autosize\":null,"
+                + "\"autocomplete\":null,\"name\":null,\"readonly\":null,\"max\":null,\"min\":null,\"step\":null,"
+                + "\"resize\":null,\"autofocus\":null,\"form\":null,\"label\":null,\"tabindex\":null,\"validateEvent\":null,"
+                + "\"showPassword\":null,\"placeholder\":\"if enable use authentication, you need input password\","
+                + "\"size\":\"small\"},\"field\":\"field8\",\"name\":\"field8\",\"type\":\"input\",\"title\":\"field8\","
+                + "\"value\":null,\"validate\":null,\"emit\":null},{\"props\":"
                 + "null,\"field\":\"field9\",\"name\":\"field9\",\"type\":\"radio\",\"title\":\"field9\","
                 + "\"value\":false,\"validate\":[{\"required\":true,\"message\":null,\"type\":\"string\","
                 + "\"trigger\":\"blur\",\"min\":null,\"max\":null}],\"emit\":null,\"options\":[{\"label\":"