Skip to content

Commit

Permalink
Fix issue in setting root path for cookies.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 16, 2023
1 parent 36b8d06 commit 7155b2c
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1503,11 +1503,21 @@ private void storeTokenIdCookie(String sessionId, HttpServletRequest req, HttpSe
if (IdentityTenantUtil.isTenantedSessionsEnabled() &&
sessionId.endsWith(SAMLSSOConstants.TENANT_QUALIFIED_TOKEN_ID_COOKIE_SUFFIX)) {
if (loggedInTenantDomain != null) {
samlssoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + loggedInTenantDomain +
SAMLSSOConstants.COOKIE_ROOT_PATH);
if (!IdentityTenantUtil.isSuperTenantRequiredInUrl() &&
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(loggedInTenantDomain)) {
samlssoTokenIdCookie.setPath(SAMLSSOConstants.COOKIE_ROOT_PATH);
} else {
samlssoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + loggedInTenantDomain +
SAMLSSOConstants.COOKIE_ROOT_PATH);
}
} else {
samlssoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + tenantDomain +
SAMLSSOConstants.COOKIE_ROOT_PATH);
if (!IdentityTenantUtil.isSuperTenantRequiredInUrl() &&
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
samlssoTokenIdCookie.setPath(SAMLSSOConstants.COOKIE_ROOT_PATH);
} else {
samlssoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + tenantDomain +
SAMLSSOConstants.COOKIE_ROOT_PATH);
}
}
isTenantQualifiedCookie = true;
} else {
Expand Down Expand Up @@ -1560,8 +1570,14 @@ public void removeTokenIdCookie(HttpServletRequest req, HttpServletResponse resp
boolean isTenantQualifiedCookie = false;
if (IdentityTenantUtil.isTenantedSessionsEnabled() && cookie.getValue() != null &&
cookie.getValue().endsWith(SAMLSSOConstants.TENANT_QUALIFIED_TOKEN_ID_COOKIE_SUFFIX)) {
samlSsoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + loggedInTenantDomain +
SAMLSSOConstants.COOKIE_ROOT_PATH);

if (!IdentityTenantUtil.isSuperTenantRequiredInUrl() &&
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(loggedInTenantDomain)) {
samlSsoTokenIdCookie.setPath(SAMLSSOConstants.COOKIE_ROOT_PATH);
} else {
samlSsoTokenIdCookie.setPath(FrameworkConstants.TENANT_CONTEXT_PREFIX + loggedInTenantDomain
+ SAMLSSOConstants.COOKIE_ROOT_PATH);
}
isTenantQualifiedCookie = true;
} else {
samlSsoTokenIdCookie.setPath(SAMLSSOConstants.COOKIE_ROOT_PATH);
Expand Down

0 comments on commit 7155b2c

Please sign in to comment.