From f6196f693d5283a96ecd7ee54b5febb11dbb7733 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 | 5 +++++ 1 file changed, 5 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..ba7934a9 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 @@ -25,6 +25,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.opensaml.xmlsec.encryption.P; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.auth.service.AuthenticationContext; @@ -300,12 +301,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); }