Skip to content

Commit

Permalink
Add new config to specify to append super tenant in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 16, 2023
1 parent d503a1d commit 38ad68a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.StringJoiner;

import static org.wso2.carbon.identity.core.util.IdentityCoreConstants.PROXY_CONTEXT_PATH;
import static org.wso2.carbon.identity.core.util.IdentityTenantUtil.isSuperTenantMandatoryInUrl;
import static org.wso2.carbon.identity.core.util.IdentityTenantUtil.isSuperTenantRequiredInUrl;

/**
* Implementation for {@link ServiceURLBuilder}.
Expand Down Expand Up @@ -125,7 +125,7 @@ protected String getResolvedUrlPath(String tenantDomain) {

if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled() && !resolvedUrlContext.startsWith("t/") &&
!resolvedUrlContext.startsWith("o/")) {
if (mandateTenantedPath || isSuperTenantMandatoryInUrl() || isNotSuperTenant(tenantDomain)) {
if (mandateTenantedPath || isSuperTenantRequiredInUrl() || isNotSuperTenant(tenantDomain)) {
String organizationId = StringUtils.isNotBlank(orgId) ? orgId :
PrivilegedCarbonContext.getThreadLocalCarbonContext().getOrganizationId();
if (organizationId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public class IdentityCoreConstants {
public static final String PORTS_OFFSET = "Ports.Offset";

public static final String TENANT_NAME_FROM_CONTEXT = "TenantNameFromContext";
public static final String ENABLE_TENANT_QUALIFIED_URLS = "EnableTenantQualifiedUrls";
public static final String ENABLE_TENANTED_SESSIONS = "EnableTenantedSessions";
public static final String APPEND_SUPER_TENANT_IN_URL = "AppendSuperTenantInUrl";
public static final String ENABLE_TENANT_QUALIFIED_URLS = "TenantContext.TenantQualifiedUrls.Enable";
public static final String REQUIRED_SUPER_TENANT_IN_URLS =
"TenantContext.TenantQualifiedUrls.RequireSuperTenantInUrls";
public static final String ENABLE_TENANTED_SESSIONS = "TenantContext.TenantedSessions.Enable";
public static final String PROXY_CONTEXT_PATH = "ProxyContextPath";
public static final int DEFAULT_HTTPS_PORT = 443;
public static final String UTF_8 = "UTF-8";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public static boolean isTenantedSessionsEnabled() {
*/
public static boolean isSuperTenantRequiredInUrl() {

return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityCoreConstants.APPEND_SUPER_TENANT_IN_URL));
return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityCoreConstants.REQUIRED_SUPER_TENANT_IN_URLS));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3214,9 +3214,17 @@
-->
<EnableFederatedUserAssociation>{{user.association.enable_for_federated_users}}</EnableFederatedUserAssociation>

<EnableTenantQualifiedUrls>{{tenant_context.enable_tenant_qualified_urls}}</EnableTenantQualifiedUrls>
<EnableTenantedSessions>{{tenant_context.enable_tenanted_sessions | default(false)}}</EnableTenantedSessions>
<AppendSuperTenantInUrl>{{tenant_context.append_super_tenant_in_url | default(false)}}</AppendSuperTenantInUrl>
<TenantContext>
<TenantQualifiedUrls>
<Enable>{{tenant_context.enable_tenant_qualified_urls}}</Enable>
<RequireSuperTenantInUrls>{{tenant_context.require_super_tenant_in_urls}}</RequireSuperTenantDomain>
</TenantQualifiedUrls>

<TenantedSessions>
<Enable>{{tenant_context.enable_tenanted_sessions}}</Enable>
</TenantedSessions>
</TenantContext>


<!--
When this property is set to 'true', if the username provided during the SaaS application authentication does
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@
"user.association.enable_for_federated_users": false,
"user.enable_per_user_functionality_locking": false,
"tenant_context.enable_tenant_qualified_urls": false,
"tenant_context.require_super_tenant_in_urls": true,
"tenant_context.rewrite.webapps": [
"/oauth2/",
"/scim2/",
Expand Down

0 comments on commit 38ad68a

Please sign in to comment.