Fix *.smtp.useAuth, quota.usage.smtp.useStartTLS and *.smtp.enabledSecurityProtocols settings definitions (#9031)

* change configs definitions

* add normalization query

* add ui support

* add labels

* add end of line to SQL script
This commit is contained in:
Bernardo De Marco Gonçalves 2024-06-11 04:54:03 -03:00 committed by GitHub
parent ee39104ec0
commit 1383625c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 56 additions and 22 deletions

View File

@ -38,8 +38,10 @@ public interface AlertManager extends Manager, AlertService {
public static final ConfigKey<Boolean> AlertSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "alert.smtp.useStartTLS", "false",
"If set to true and if we enable security via alert.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
public static final ConfigKey<String> AlertSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "alert.smtp.enabledSecurityProtocols", "",
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
public static final ConfigKey<Boolean> AlertSmtpUseAuth = new ConfigKey<>(ConfigKey.CATEGORY_ALERT, Boolean.class, "alert.smtp.useAuth", "false", "If true, use SMTP authentication when sending emails.", false, ConfigKey.Scope.ManagementServer);
public static final ConfigKey<String> AlertSmtpEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "alert.smtp.enabledSecurityProtocols", "",
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
public static final ConfigKey<Double> Ipv6SubnetCapacityThreshold = new ConfigKey<Double>("Advanced", Double.class,
"zone.virtualnetwork.ipv6subnet.capacity.notificationthreshold",

View File

@ -133,3 +133,20 @@ CREATE TABLE `cloud`.`webhook_delivery` (
CONSTRAINT `fk_webhook__event_id` FOREIGN KEY (`event_id`) REFERENCES `event`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_webhook__webhook_id` FOREIGN KEY (`webhook_id`) REFERENCES `webhook`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Normalize quota.usage.smtp.useStartTLS, quota.usage.smtp.useAuth, alert.smtp.useAuth and project.smtp.useAuth values
UPDATE
`cloud`.`configuration`
SET
value = "true"
WHERE
name IN ("quota.usage.smtp.useStartTLS", "quota.usage.smtp.useAuth", "alert.smtp.useAuth", "project.smtp.useAuth")
AND value IN ("true", "y", "t", "1", "on", "yes");
UPDATE
`cloud`.`configuration`
SET
value = "false"
WHERE
name IN ("quota.usage.smtp.useStartTLS", "quota.usage.smtp.useAuth", "alert.smtp.useAuth", "project.smtp.useAuth")
AND value NOT IN ("true", "y", "t", "1", "on", "yes");

View File

@ -41,7 +41,7 @@ public class ConfigKey<T> {
}
public enum Kind {
CSV, Order, Select
CSV, Order, Select, WhitespaceSeparatedListWithOptions
}
private final String _category;
@ -136,6 +136,10 @@ public class ConfigKey<T> {
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null);
}
public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, Kind kind, String options) {
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null, null, null, null, null, kind, options);
}
public ConfigKey(String category, Class<T> type, String name, String defaultValue, String description, boolean isDynamic, String parent) {
this(type, name, category, defaultValue, description, isDynamic, Scope.Global, null, null, parent, null, null, null, null);
}

View File

@ -48,16 +48,16 @@ public interface QuotaConfig {
public static final ConfigKey<String> QuotaSmtpPort = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.port", "", "Quota SMTP port.", true);
public static final ConfigKey<String> QuotaSmtpAuthType = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.useAuth", "",
public static final ConfigKey<Boolean> QuotaSmtpAuthType = new ConfigKey<Boolean>("Advanced", Boolean.class, "quota.usage.smtp.useAuth", "false",
"If true, use secure SMTP authentication when sending emails.", true);
public static final ConfigKey<String> QuotaSmtpSender = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.sender", "",
"Sender of quota alert email (will be in the From header of the email).", true);
public static final ConfigKey<String> QuotaSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.enabledSecurityProtocols", "",
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2.", true);
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2.", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
public static final ConfigKey<String> QuotaSmtpUseStartTLS = new ConfigKey<String>("Advanced", String.class, "quota.usage.smtp.useStartTLS", "false",
public static final ConfigKey<Boolean> QuotaSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "quota.usage.smtp.useStartTLS", "false",
"If set to true and if we enable security via quota.usage.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
public static final ConfigKey<Long> QuotaActivationRuleTimeout = new ConfigKey<>("Advanced", Long.class, "quota.activationrule.timeout", "2000", "The maximum runtime,"

View File

@ -800,7 +800,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {CPUCapacityThreshold, MemoryCapacityThreshold, StorageAllocatedCapacityThreshold, StorageCapacityThreshold, AlertSmtpEnabledSecurityProtocols,
AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold};
AlertSmtpUseStartTLS, Ipv6SubnetCapacityThreshold, AlertSmtpUseAuth};
}
@Override

View File

@ -78,7 +78,6 @@ public enum Config {
"30000",
"Socket I/O timeout value in milliseconds. -1 for infinite timeout.",
null),
AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, "alert.smtp.useAuth", null, "If true, use SMTP authentication when sending emails.", null),
AlertSMTPUsername(
"Alert",
ManagementServer.class,
@ -1547,14 +1546,6 @@ public enum Config {
"Password for SMTP authentication (applies only if project.smtp.useAuth is true)",
null),
ProjectSMTPPort("Project Defaults", ManagementServer.class, Integer.class, "project.smtp.port", "465", "Port the SMTP server is listening on", null),
ProjectSMTPUseAuth(
"Project Defaults",
ManagementServer.class,
String.class,
"project.smtp.useAuth",
null,
"If true, use SMTP authentication when sending emails",
null),
ProjectSMTPUsername(
"Project Defaults",
ManagementServer.class,

View File

@ -22,11 +22,14 @@ import com.cloud.user.Account;
import org.apache.cloudstack.framework.config.ConfigKey;
public interface ProjectManager extends ProjectService {
public static final ConfigKey<Boolean> ProjectSmtpUseStartTLS = new ConfigKey<Boolean>("Advanced", Boolean.class, "project.smtp.useStartTLS", "false",
public static final ConfigKey<Boolean> ProjectSmtpUseStartTLS = new ConfigKey<Boolean>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "project.smtp.useStartTLS", "false",
"If set to true and if we enable security via project.smtp.useAuth, this will enable StartTLS to secure the connection.", true);
public static final ConfigKey<String> ProjectSmtpEnabledSecurityProtocols = new ConfigKey<String>("Advanced", String.class, "project.smtp.enabledSecurityProtocols", "",
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true);
public static final ConfigKey<String> ProjectSmtpEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED, String.class, "project.smtp.enabledSecurityProtocols", "",
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2", true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
public static final ConfigKey<Boolean> ProjectSmtpUseAuth = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "project.smtp.useAuth", "false",
"If true, use SMTP authentication when sending emails", false, ConfigKey.Scope.ManagementServer);
boolean canAccessProjectAccount(Account caller, long accountId);

View File

@ -1451,7 +1451,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager, C
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS};
return new ConfigKey<?>[] {ProjectSmtpEnabledSecurityProtocols, ProjectSmtpUseStartTLS, ProjectSmtpUseAuth};
}
protected void updateProjectNameAndDisplayText(final ProjectVO project, String name, String displayText) {

View File

@ -3185,6 +3185,7 @@
"message.scaleup.policy.name.continue": "Please input a name to ScaleUp policy to continue",
"message.select.a.zone": "A zone typically corresponds to a single datacenter. Multiple zones help make the cloud more reliable by providing physical isolation and redundancy.",
"message.select.affinity.groups": "Please select any affinity groups you want this Instance to belong to:",
"message.select.deselect.desired.options": "Please select / deselect the desired options",
"message.select.deselect.to.sort": "Please select / deselect to sort the values",
"message.select.destination.image.stores": "Please select Image Store(s) to which data is to be migrated to",
"message.select.disk.offering": "Please select a disk offering for disk",

View File

@ -2317,6 +2317,7 @@
"message.scale.processing": "Escalonamento em progresso",
"message.select.a.zone": "A zona tipicamente corresponde a um \u00fanico datacenter. M\u00faltiplas zonas auxiliam a nuvem a ser mais confi\u00e1vel provendo isolamento f\u00edsico e redund\u00e2ncia.",
"message.select.affinity.groups": "Por favor, selecione quaisquer grupos de afinidade que voc\u00ea deseja que esta VM perten\u00e7a:",
"message.select.deselect.desired.options": "Por favor, selecione / desselecione as op\u00e7\u00f5es desejadas",
"message.select.destination.image.stores": "Por favor, selecione o(s) armazenamento(s) de imagem(ns) para os quais os dados devem ser migrados",
"message.select.disk.offering": "Por favor, selecione uma oferta de disco para o disco",
"message.select.end.date.and.time": "Selecione uma data e hor\u00e1rio final.",

View File

@ -110,9 +110,14 @@
</a-select>
</a-tooltip>
</span>
<span v-else-if="configrecord.type === 'Order'">
<span v-else-if="configrecord.type === 'Order' || configrecord.type === 'WhitespaceSeparatedListWithOptions'">
<a-tooltip :title="editableValue.join(', ')">
<b>{{ $t('message.select.deselect.to.sort') }}</b>
<b v-if="configrecord.type === 'Order'">
{{ $t('message.select.deselect.to.sort') }}
</b>
<b v-else>
{{ $t('message.select.deselect.desired.options') }}
</b>
<br />
<a-select
style="width: 20vw"
@ -241,6 +246,9 @@ export default {
if (['Order', 'CSV'].includes(configrecord.type)) {
newValue = newValue.join(',')
}
if (configrecord.type === 'WhitespaceSeparatedListWithOptions') {
newValue = newValue.join(' ')
}
const params = {
name: configrecord.name,
value: newValue
@ -332,6 +340,13 @@ export default {
return []
}
}
if (configrecord.type === 'WhitespaceSeparatedListWithOptions') {
if (configrecord.value && configrecord.value.length > 0) {
return String(configrecord.value).split(' ')
}
return []
}
if (configrecord.value) {
return String(configrecord.value)
}