server: add user.password.reset.smtp.useStartTLS and enabledSecurityProtocols for password reset (#11228)

This commit is contained in:
Wei Zhou 2025-10-07 06:49:57 +02:00 committed by GitHub
parent 8e4dc0a66d
commit 963a67b816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,17 @@ public interface UserPasswordResetManager {
"Use auth in the SMTP server for sending emails for resetting password for ACS users", "Use auth in the SMTP server for sending emails for resetting password for ACS users",
false, ConfigKey.Scope.Global); false, ConfigKey.Scope.Global);
ConfigKey<Boolean> UserPasswordResetSMTPUseStartTLS = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
Boolean.class, "user.password.reset.smtp.useStartTLS", "false",
"If set to true and if we enable security via user.password.reset.smtp.useAuth, this will enable StartTLS to secure the connection.",
true,
ConfigKey.Scope.Global);
ConfigKey<String> UserPasswordResetSMTPEnabledSecurityProtocols = new ConfigKey<String>(ConfigKey.CATEGORY_ADVANCED,
String.class, "user.password.reset.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");
ConfigKey<String> UserPasswordResetSMTPUsername = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, ConfigKey<String> UserPasswordResetSMTPUsername = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED,
String.class, "user.password.reset.smtp.username", null, String.class, "user.password.reset.smtp.username", null,
"Username for SMTP server for sending emails for resetting password for ACS users", "Username for SMTP server for sending emails for resetting password for ACS users",

View File

@ -93,6 +93,8 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
UserPasswordResetSMTPHost, UserPasswordResetSMTPHost,
UserPasswordResetSMTPPort, UserPasswordResetSMTPPort,
UserPasswordResetSMTPUseAuth, UserPasswordResetSMTPUseAuth,
UserPasswordResetSMTPUseStartTLS,
UserPasswordResetSMTPEnabledSecurityProtocols,
UserPasswordResetSMTPUsername, UserPasswordResetSMTPUsername,
UserPasswordResetSMTPPassword, UserPasswordResetSMTPPassword,
PasswordResetMailTemplate PasswordResetMailTemplate
@ -106,6 +108,8 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
Boolean useAuth = UserPasswordResetSMTPUseAuth.value(); Boolean useAuth = UserPasswordResetSMTPUseAuth.value();
String username = UserPasswordResetSMTPUsername.value(); String username = UserPasswordResetSMTPUsername.value();
String password = UserPasswordResetSMTPPassword.value(); String password = UserPasswordResetSMTPPassword.value();
Boolean useStartTLS = UserPasswordResetSMTPUseStartTLS.value();
String enabledSecurityProtocols = UserPasswordResetSMTPEnabledSecurityProtocols.value();
if (!StringUtils.isEmpty(smtpHost) && smtpPort != null && smtpPort > 0) { if (!StringUtils.isEmpty(smtpHost) && smtpPort != null && smtpPort > 0) {
String namespace = "password.reset.smtp"; String namespace = "password.reset.smtp";
@ -117,6 +121,8 @@ public class UserPasswordResetManagerImpl extends ManagerBase implements UserPas
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USE_AUTH), useAuth.toString()); configs.put(getKey(namespace, SMTPMailSender.CONFIG_USE_AUTH), useAuth.toString());
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USERNAME), username); configs.put(getKey(namespace, SMTPMailSender.CONFIG_USERNAME), username);
configs.put(getKey(namespace, SMTPMailSender.CONFIG_PASSWORD), password); configs.put(getKey(namespace, SMTPMailSender.CONFIG_PASSWORD), password);
configs.put(getKey(namespace, SMTPMailSender.CONFIG_USE_STARTTLS), useStartTLS.toString());
configs.put(getKey(namespace, SMTPMailSender.CONFIG_ENABLED_SECURITY_PROTOCOLS), enabledSecurityProtocols);
mailSender = new SMTPMailSender(configs, namespace); mailSender = new SMTPMailSender(configs, namespace);
} }