Skip to content

Commit 963a67b

Browse files
server: add user.password.reset.smtp.useStartTLS and enabledSecurityProtocols for password reset (#11228)
1 parent 8e4dc0a commit 963a67b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ public interface UserPasswordResetManager {
5555
"Use auth in the SMTP server for sending emails for resetting password for ACS users",
5656
false, ConfigKey.Scope.Global);
5757

58+
ConfigKey<Boolean> UserPasswordResetSMTPUseStartTLS = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
59+
Boolean.class, "user.password.reset.smtp.useStartTLS", "false",
60+
"If set to true and if we enable security via user.password.reset.smtp.useAuth, this will enable StartTLS to secure the connection.",
61+
true,
62+
ConfigKey.Scope.Global);
63+
64+
ConfigKey<String> UserPasswordResetSMTPEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED,
65+
String.class, "user.password.reset.smtp.enabledSecurityProtocols", "",
66+
"White-space separated security protocols; ex: \"TLSv1 TLSv1.1\". Supported protocols: SSLv2Hello, SSLv3, TLSv1, TLSv1.1 and TLSv1.2",
67+
true, ConfigKey.Kind.WhitespaceSeparatedListWithOptions, "SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2");
68+
5869
ConfigKey<String> UserPasswordResetSMTPUsername = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
5970
String.class, "user.password.reset.smtp.username", null,
6071
"Username for SMTP server for sending emails for resetting password for ACS users",

server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public ConfigKey<?>[] getConfigKeys() {
9393
UserPasswordResetSMTPHost,
9494
UserPasswordResetSMTPPort,
9595
UserPasswordResetSMTPUseAuth,
96+
UserPasswordResetSMTPUseStartTLS,
97+
UserPasswordResetSMTPEnabledSecurityProtocols,
9698
UserPasswordResetSMTPUsername,
9799
UserPasswordResetSMTPPassword,
98100
PasswordResetMailTemplate
@@ -106,6 +108,8 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
106108
Boolean useAuth = UserPasswordResetSMTPUseAuth.value();
107109
String username = UserPasswordResetSMTPUsername.value();
108110
String password = UserPasswordResetSMTPPassword.value();
111+
Boolean useStartTLS = UserPasswordResetSMTPUseStartTLS.value();
112+
String enabledSecurityProtocols = UserPasswordResetSMTPEnabledSecurityProtocols.value();
109113

110114
if (!StringUtils.isEmpty(smtpHost) && smtpPort != null && smtpPort > 0) {
111115
String namespace = "password.reset.smtp";
@@ -117,6 +121,8 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
117121
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USE_AUTH), useAuth.toString());
118122
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USERNAME), username);
119123
configs.put(getKey(namespace, SMTPMailSender.CONFIG_PASSWORD), password);
124+
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USE_STARTTLS), useStartTLS.toString());
125+
configs.put(getKey(namespace, SMTPMailSender.CONFIG_ENABLED_SECURITY_PROTOCOLS), enabledSecurityProtocols);
120126

121127
mailSender = new SMTPMailSender(configs, namespace);
122128
}

0 commit comments

Comments
 (0)