Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new config to specify to append super tenant in URL #4990

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.isSuperTenantRequiredInUrl;

/**
* 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 || 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,8 +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 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.TenantQualifiedUrls.EnableTenantedSessions";
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.REQUIRED_SUPER_TENANT_IN_URLS));
}

/**
*
* Checks whether legacy SaaS authentication is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,14 @@
-->
<EnableFederatedUserAssociation>false</EnableFederatedUserAssociation>

<TenantContext>
<TenantQualifiedUrls>
<Enable>false</Enable>
<RequireSuperTenantInUrls>false</RequireSuperTenantInUrls>
<EnableTenantedSessions>false</EnableTenantedSessions>
</TenantQualifiedUrls>
</TenantContext>

<TenantContextsToRewrite>
<WebApp>
<Context>/api/identity/user/v1.0/</Context>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3214,8 +3214,14 @@
-->
<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>
<TenantContext>
<TenantQualifiedUrls>
<Enable>{{tenant_context.enable_tenant_qualified_urls}}</Enable>
<RequireSuperTenantInUrls>{{tenant_context.enable_tenant_qualified_urls && tenant_context.require_super_tenant_in_urls}}</RequireSuperTenantInUrls>
<EnableTenantedSessions>{{tenant_context.enable_tenant_qualified_urls && tenant_context.enable_tenanted_sessions}}</EnableTenantedSessions>
</TenantQualifiedUrls>
</TenantContext>
Thisara-Welmilla marked this conversation as resolved.
Show resolved Hide resolved


<!--
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": false,
"tenant_context.rewrite.webapps": [
"/oauth2/",
"/scim2/",
Expand Down
Loading