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

* [Improvement-11913] Mask password when creating/editing alert instances
This commit is contained in:
c3Vu 2023-06-28 14:10:51 +08:00 committed by GitHub
parent 7a24be0672
commit 50195c46aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 103 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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);
}
}
}

View File

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