From 404cb05531e5aa4307a5fce079a13bec426a403f Mon Sep 17 00:00:00 2001 From: sadilchamishka Date: Fri, 27 Oct 2023 18:17:10 +0530 Subject: [PATCH] Set authenticated user information in the organization bound tenanted context --- .../wso2/carbon/identity/authz/valve/AuthorizationValve.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java b/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java index ebb762e0..d16875a9 100644 --- a/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java +++ b/components/org.wso2.carbon.identity.authz.valve/src/main/java/org/wso2/carbon/identity/authz/valve/AuthorizationValve.java @@ -300,12 +300,16 @@ private boolean isAuthorizationSkipped(String authHandlerName, String requestUri private void startOrganizationBoundTenantFlow(String authorizedOrganization) { + String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setOrganizationId(authorizedOrganization); try { String authorizedTenantDomain = AuthorizationValveServiceHolder.getInstance().getOrganizationManager() .resolveTenantDomain(authorizedOrganization); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(authorizedTenantDomain, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserId(userId); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName); } catch (OrganizationManagementException e) { throw new AuthRuntimeException("Error while resolving tenant domain by organization.", e); }