Skip to content

Commit

Permalink
Merge pull request #249 from sadilchamishka/set-user-id-carbon-context
Browse files Browse the repository at this point in the history
Set authenticated user information in the organization bound tenanted context
  • Loading branch information
sadilchamishka authored Oct 27, 2023
2 parents e10a03a + 404cb05 commit 56b2901
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 56b2901

Please sign in to comment.