Skip to content

Commit

Permalink
Introduce new threadlocal property to store the root tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Nov 9, 2023
1 parent 80595b6 commit 6d1cdc0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion components/org.wso2.carbon.identity.authz.valve/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.authz.service</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.organization.management.core</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.service</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -90,7 +94,8 @@
org.wso2.carbon.identity.core.*; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.authz.service.*;version="${org.wso2.carbon.identity.authz.service.version.range}",
org.apache.catalina.*;version="1.7.0",
org.wso2.carbon.identity.organization.management.authz.service; version="${org.wso2.carbon.identity.organization.management.version.range}"
org.wso2.carbon.identity.organization.management.authz.service; version="${org.wso2.carbon.identity.organization.management.version.range}",
org.wso2.carbon.identity.organization.management.service.constant; version="${org.wso2.carbon.identity.organization.management.core.version.range}"
</Import-Package>
<Export-Package>!org.wso2.carbon.identity.authz.valve.internal,
org.wso2.carbon.identity.authz.valve.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
import org.wso2.carbon.identity.authz.service.exception.AuthzServiceServerException;
import org.wso2.carbon.identity.authz.valve.internal.AuthorizationValveServiceHolder;
import org.wso2.carbon.identity.authz.valve.util.Utils;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.organization.management.authz.service.OrganizationManagementAuthorizationContext;
import org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;

Expand All @@ -55,6 +57,7 @@
import javax.servlet.http.HttpServletResponse;

import static org.wso2.carbon.identity.auth.service.util.Constants.ENGAGED_AUTH_HANDLER;
import static org.wso2.carbon.identity.auth.service.util.Constants.IDP_NAME;
import static org.wso2.carbon.identity.auth.service.util.Constants.OAUTH2_ALLOWED_SCOPES;
import static org.wso2.carbon.identity.auth.service.util.Constants.OAUTH2_VALIDATE_SCOPE;

Expand Down Expand Up @@ -170,6 +173,8 @@ public void invoke(Request request, Response response) throws IOException, Servl
getNext().invoke(request, response);
} finally {
PrivilegedCarbonContext.endTenantFlow();
IdentityUtil.threadLocalProperties.get()
.remove(OrganizationManagementConstants.ROOT_TENANT_DOMAIN);
}
} else {
getNext().invoke(request, response);
Expand Down Expand Up @@ -300,6 +305,8 @@ private boolean isAuthorizationSkipped(String authHandlerName, String requestUri

private void startOrganizationBoundTenantFlow(String authorizedOrganization) {

String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
IdentityUtil.threadLocalProperties.get().put(OrganizationManagementConstants.ROOT_TENANT_DOMAIN, tenantDomain);
String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId();
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
String userResidentOrganizationId = PrivilegedCarbonContext.getThreadLocalCarbonContext()
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
</org.wso2.carbon.identity.organization.management.version>
<org.wso2.carbon.identity.organization.management.version.range>[1.0.0, 2.0.0)
</org.wso2.carbon.identity.organization.management.version.range>
<org.wso2.carbon.identity.organization.management.core.version>1.0.17
<org.wso2.carbon.identity.organization.management.core.version>1.0.85
</org.wso2.carbon.identity.organization.management.core.version>
<org.wso2.carbon.identity.organization.management.core.version.range>[1.0.0, 2.0.0)
</org.wso2.carbon.identity.organization.management.core.version.range>
Expand Down

0 comments on commit 6d1cdc0

Please sign in to comment.