Skip to content

Commit

Permalink
Refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 11, 2023
1 parent 7c8dc56 commit e5b99ca
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +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;

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

if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled() && !resolvedUrlContext.startsWith("t/") &&
!resolvedUrlContext.startsWith("o/")) {
if (mandateTenantedPath || isNotSuperTenant(tenantDomain)) {
if (mandateTenantedPath || isSuperTenantMandatoryInUrl() || 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 @@ -37,6 +37,7 @@ public class IdentityCoreConstants {
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 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 @@ -422,6 +422,16 @@ public static boolean isTenantedSessionsEnabled() {
return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityCoreConstants.ENABLE_TENANTED_SESSIONS));
}

/**
* Checks if it is required to specify carbon.super in tenant qualified URLs.
*
* @return true if it is mandatory, false otherwise
*/
public static boolean isSuperTenantRequiredInUrl() {

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

/**
*
* Checks whether legacy SaaS authentication is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,7 @@

<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>

<!--
When this property is set to 'true', if the username provided during the SaaS application authentication does
Expand Down

0 comments on commit e5b99ca

Please sign in to comment.