Skip to content

Commit

Permalink
Improve setting cookie path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Nov 14, 2023
1 parent 1924c75 commit e6a09f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ private void setAuthCookie(HttpServletRequest request, HttpServletResponse respo
if (FrameworkUtils.isOrganizationQualifiedRequest()) {
path = FrameworkConstants.ORGANIZATION_CONTEXT_PREFIX + context.getLoginTenantDomain() + "/";
} else {
if (!IdentityTenantUtil.isSuperTenantRequiredInUrl() &&
if (!IdentityTenantUtil.isSuperTenantAppendInCookiePath() &&
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(context.getLoginTenantDomain())) {
path = "/";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class IdentityCoreConstants {
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 APPEND_SUPER_TENANT_IN_COOKIE_PATH =
"TenantContext.TenantQualifiedUrls.AppendSuperTenantInCookiePath";
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,16 @@ public static boolean isSuperTenantRequiredInUrl() {
return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityCoreConstants.REQUIRED_SUPER_TENANT_IN_URLS));
}

/**
* Checks if it is required to append the carbon.super in cookie path.
*
* @return true if it is mandatory, false otherwise.
*/
public static boolean isSuperTenantAppendInCookiePath() {

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

/**
*
* Checks whether legacy SaaS authentication is enabled.
Expand Down

0 comments on commit e6a09f1

Please sign in to comment.