Skip to content

Commit 32d110f

Browse files
committed
Custom login base domain using GUI whitelabel themes
1 parent 2fd83e1 commit 32d110f

14 files changed

Lines changed: 120 additions & 23 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ public class ApiConstants {
13971397
public static final String CSS = "css";
13981398

13991399
public static final String JSON_CONFIGURATION = "jsonconfiguration";
1400+
public static final String LOGIN_BASE_DOMAIN = "loginbasedomain";
14001401

14011402
public static final String COMMON_NAMES = "commonnames";
14021403

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class CreateGuiThemeCmd extends BaseCmd {
5757
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
5858
private String commonNames;
5959

60+
@Parameter(name = ApiConstants.LOGIN_BASE_DOMAIN, type = CommandType.STRING, length = 65535, description = "The ACS domain to be used as base " +
61+
"for the login when accessing the GUI through the common name defined in the theme. If a common name is not defined, this parameter is ignored on the GUI.")
62+
private String loginBaseDomain;
63+
6064
@Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " +
6165
"the end-user) separated by comma that can retrieve the theme.")
6266
private String domainIds;
@@ -93,6 +97,10 @@ public String getCommonNames() {
9397
return commonNames;
9498
}
9599

100+
public String getLoginBaseDomain() {
101+
return loginBaseDomain;
102+
}
103+
96104
public String getDomainIds() {
97105
return domainIds;
98106
}

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/UpdateGuiThemeCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public class UpdateGuiThemeCmd extends BaseCmd {
6060
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
6161
private String commonNames;
6262

63+
@Parameter(name = ApiConstants.LOGIN_BASE_DOMAIN, type = CommandType.STRING, length = 65535, description = "The ACS domain to be used as base for " +
64+
"the login when accessing the GUI through the common name defined in the theme. If a common name is not defined, this parameter is ignored on the GUI.")
65+
private String loginBaseDomain;
66+
6367
@Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " +
6468
"the end-user) separated by comma that can retrieve the theme.")
6569
private String domainIds;
@@ -96,6 +100,10 @@ public String getJsonConfiguration() {
96100
return jsonConfiguration;
97101
}
98102

103+
public String getLoginBaseDomain() {
104+
return loginBaseDomain;
105+
}
106+
99107
public String getCommonNames() {
100108
return commonNames;
101109
}

api/src/main/java/org/apache/cloudstack/api/response/GuiThemeResponse.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public class GuiThemeResponse extends BaseResponse {
5252
@Param(description = "A set of Common Names (CN) (fixed or wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
5353
private String commonNames;
5454

55+
@SerializedName(ApiConstants.LOGIN_BASE_DOMAIN)
56+
@Param(description = "The ACS domain to be used as base for the login when accessing the GUI through the common name defined in the theme. If a " +
57+
"common name is not defined, this parameter is ignored on the GUI.")
58+
private String loginBaseDomain;
59+
5560
@SerializedName(ApiConstants.DOMAIN_IDS)
5661
@Param(description = "A set of domain UUIDs (also known as ID for the end-user) separated by comma that can retrieve the theme.")
5762
private String domainIds;
@@ -176,4 +181,12 @@ public void setRecursiveDomains(Boolean recursiveDomains) {
176181
public void setRemoved(Date removed) {
177182
this.removed = removed;
178183
}
184+
185+
public String getLoginBaseDomain() {
186+
return loginBaseDomain;
187+
}
188+
189+
public void setLoginBaseDomain(String loginBaseDomain) {
190+
this.loginBaseDomain = loginBaseDomain;
191+
}
179192
}

api/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeJoin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ public interface GuiThemeJoin extends InternalIdentity, Identity {
4444
Date getCreated();
4545

4646
Date getRemoved();
47+
48+
String getLoginBaseDomain();
4749
}

engine/schema/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeJoinVO.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public class GuiThemeJoinVO implements GuiThemeJoin {
6363
@Column(name = "is_public")
6464
private boolean isPublic;
6565

66+
@Column(name = "login_base_domain")
67+
private String loginBaseDomain;
68+
6669
@Column(name = GenericDao.CREATED_COLUMN, nullable = false)
6770
@Temporal(value = TemporalType.TIMESTAMP)
6871
private Date created;
@@ -138,4 +141,9 @@ public Date getCreated() {
138141
public Date getRemoved() {
139142
return removed;
140143
}
144+
145+
@Override
146+
public String getLoginBaseDomain() {
147+
return loginBaseDomain;
148+
}
141149
}

engine/schema/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeVO.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public class GuiThemeVO implements GuiTheme {
5959
@Column(name = "recursive_domains")
6060
private boolean recursiveDomains = false;
6161

62+
@Column(name = "login_base_domain", length = 65535)
63+
private String loginBaseDomain;
64+
6265
@Column(name = GenericDao.CREATED_COLUMN, nullable = false)
6366
@Temporal(value = TemporalType.TIMESTAMP)
6467
private Date created;
@@ -71,14 +74,16 @@ public GuiThemeVO() {
7174

7275
}
7376

74-
public GuiThemeVO(String name, String description, String css, String jsonConfiguration, boolean recursiveDomains, boolean isPublic, Date created, Date removed) {
77+
public GuiThemeVO(String name, String description, String css, String jsonConfiguration, boolean recursiveDomains,
78+
boolean isPublic, Date created, String loginBaseDomain, Date removed) {
7579
this.name = name;
7680
this.description = description;
7781
this.css = css;
7882
this.jsonConfiguration = jsonConfiguration;
7983
this.recursiveDomains = recursiveDomains;
8084
this.isPublic = isPublic;
8185
this.created = created;
86+
this.loginBaseDomain = loginBaseDomain;
8287
this.removed = removed;
8388
}
8489

@@ -186,4 +191,8 @@ public void setRecursiveDomains(boolean recursiveDomains) {
186191
public String toString() {
187192
return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "uuid", "name", "description", "isPublic", "recursiveDomains");
188193
}
194+
195+
public void setLoginBaseDomain(String loginBaseDomain) {
196+
this.loginBaseDomain = loginBaseDomain;
197+
}
189198
}

engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,6 @@ INSERT INTO cloud.role_permissions (uuid, role_id, rule, permission, sort_order)
208208
SELECT uuid(), role_id, 'quotaResourceStatement', permission, sort_order
209209
FROM cloud.role_permissions rp
210210
WHERE rule = 'quotaStatement' AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 'quotaResourceStatement');
211+
212+
--- Gui theme login base domain
213+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.gui_themes', 'login_base_domain', 'TEXT DEFAULT NULL');

engine/schema/src/main/resources/META-INF/db/views/cloud.gui_themes_view.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SELECT
2727
`cloud`.`gui_themes`.`description` AS `description`,
2828
`cloud`.`gui_themes`.`css` AS `css`,
2929
`cloud`.`gui_themes`.`json_configuration` AS `json_configuration`,
30+
`cloud`.`gui_themes`.`login_base_domain` AS `login_base_domain`,
3031
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'commonName' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) common_names,
3132
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'domain' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) domains,
3233
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'account' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) accounts,

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5719,6 +5719,7 @@ public GuiThemeResponse createGuiThemeResponse(GuiThemeJoin guiThemeJoin) {
57195719

57205720
guiThemeResponse.setJsonConfiguration(guiThemeJoin.getJsonConfiguration());
57215721
guiThemeResponse.setCss(guiThemeJoin.getCss());
5722+
guiThemeResponse.setLoginBaseDomain(guiThemeJoin.getLoginBaseDomain());
57225723
guiThemeResponse.setResponseName("guithemes");
57235724

57245725
return guiThemeResponse;

0 commit comments

Comments
 (0)