You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "Damans227 (via GitHub)" <gi...@apache.org> on 2026/10/15 13:51:16 UTC
Re: [PR] Refactor password reset link domain flow [cloudstack]
Damans227 commented on code in PR #13209:
URL: https://github.com/apache/cloudstack/pull/13209#discussion_r4283820239
##########
server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManagerImpl.java:
##########
@@ -222,6 +215,44 @@ public void setResetTokenAndSend(UserAccount userAccount) {
userAccount, userAccount.getAccountId(), userAccount.getDomainId(), email, resetTokenExpiryTime);
}
+ private String getResetLinkDomain(String requestDomain) {
+ if (StringUtils.isNotBlank(requestDomain)) {
+ logger.debug("Searching for GUI theme with common name that matches the request's domain: [{}]", requestDomain);
+ List<Long> commonNameDetails = guiThemeDetailsDao.listGuiThemeIdsByCommonName(requestDomain);
+
+ if (!commonNameDetails.isEmpty()) {
+ logger.debug("GUI theme with ID {} was found; using request's domain for password reset link.", commonNameDetails.get(0));
+ return requestDomain;
+ } else {
+ logger.debug("No GUI theme was found with a common name that matches the request's domain.");
+ }
+ }
+
+ String configurationDomain = UserPasswordResetDomainURL.value();
+ if (StringUtils.isNotBlank(configurationDomain)) {
+ logger.debug("Defaulting reset link's domain to the [{}] configuration value: [{}].", UserPasswordResetDomainURL.key(), UserPasswordResetDomainURL.value());
+ return configurationDomain;
+ }
+
+ logger.debug("Using the first IP address in the [{}] configuration for the reset password email domain because the [{}] configuration is not defined.", ManagementServerAddresses.key(), UserPasswordResetDomainURL.key());
+ return ManagementServerAddresses.value().split(",")[0];
+ }
+
+ private String formatResetLinkDomain(String resetLinkDomain) {
+ String protocol = ServerProperties.isHttpsEnabled() ? "https" : "http";
+
+ if (InetAddressUtils.isIPv4Address(resetLinkDomain)) {
Review Comment:
if the host setting is a name instead of an ip, the link loses the port now. wont that break setups that serve the ui on 8080 with no proxy?
##########
server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManagerImpl.java:
##########
@@ -222,6 +215,44 @@ public void setResetTokenAndSend(UserAccount userAccount) {
userAccount, userAccount.getAccountId(), userAccount.getDomainId(), email, resetTokenExpiryTime);
}
+ private String getResetLinkDomain(String requestDomain) {
+ if (StringUtils.isNotBlank(requestDomain)) {
+ logger.debug("Searching for GUI theme with common name that matches the request's domain: [{}]", requestDomain);
+ List<Long> commonNameDetails = guiThemeDetailsDao.listGuiThemeIdsByCommonName(requestDomain);
+
+ if (!commonNameDetails.isEmpty()) {
+ logger.debug("GUI theme with ID {} was found; using request's domain for password reset link.", commonNameDetails.get(0));
+ return requestDomain;
+ } else {
+ logger.debug("No GUI theme was found with a common name that matches the request's domain.");
+ }
+ }
+
+ String configurationDomain = UserPasswordResetDomainURL.value();
+ if (StringUtils.isNotBlank(configurationDomain)) {
+ logger.debug("Defaulting reset link's domain to the [{}] configuration value: [{}].", UserPasswordResetDomainURL.key(), UserPasswordResetDomainURL.value());
+ return configurationDomain;
+ }
+
+ logger.debug("Using the first IP address in the [{}] configuration for the reset password email domain because the [{}] configuration is not defined.", ManagementServerAddresses.key(), UserPasswordResetDomainURL.key());
+ return ManagementServerAddresses.value().split(",")[0];
+ }
+
+ private String formatResetLinkDomain(String resetLinkDomain) {
+ String protocol = ServerProperties.isHttpsEnabled() ? "https" : "http";
+
+ if (InetAddressUtils.isIPv4Address(resetLinkDomain)) {
+ int port = protocol.equals("https") ? ServerProperties.getHttpsPort() : ServerProperties.getHttpPort();
+ resetLinkDomain = resetLinkDomain + ":" + port;
+ }
+
+ if (!resetLinkDomain.startsWith("http")) {
Review Comment:
should this check for http:// and https:// like before? a name like httpd.example.com would never get the scheme added here
##########
server/src/main/java/org/apache/cloudstack/user/UserPasswordResetManagerImpl.java:
##########
@@ -222,6 +215,44 @@ public void setResetTokenAndSend(UserAccount userAccount) {
userAccount, userAccount.getAccountId(), userAccount.getDomainId(), email, resetTokenExpiryTime);
}
+ private String getResetLinkDomain(String requestDomain) {
+ if (StringUtils.isNotBlank(requestDomain)) {
+ logger.debug("Searching for GUI theme with common name that matches the request's domain: [{}]", requestDomain);
+ List<Long> commonNameDetails = guiThemeDetailsDao.listGuiThemeIdsByCommonName(requestDomain);
Review Comment:
does this also match removed themes? removing a theme keeps its details, so an old common name would still match here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org