Skip to content

Commit

Permalink
Improve organization user check
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Feb 9, 2024
1 parent a56ff41 commit 8afedcd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ protected void postAuthenticate(MessageContext messageContext, AuthenticationRes
AuthenticatedUser authenticatedUser;
if (user instanceof AuthenticatedUser) {
authenticatedUser = (AuthenticatedUser) user;
// For B2B organization users, set the user ID which is set as username in user object.
if (authenticatedUser.isFederatedUser() && StringUtils.isNotEmpty(authorizedOrganization)) {
/* For users whose identity is managed in an organization, will be authenticated using the
organization SSO. As being a federated login user, the username is populated with
corresponding user ID. */
if (authenticatedUser.isOrganizationUser()) {
String userName = MultitenantUtils.getTenantAwareUsername(authenticatedUser.getUserName());
userName = UserCoreUtil.removeDomainFromName(userName);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUserId(userName);
Expand All @@ -146,7 +148,7 @@ protected void postAuthenticate(MessageContext messageContext, AuthenticationRes
}

if (StringUtils.isNotEmpty(authorizedOrganization)) {
// Set the user's resident organization if user is accessing an organization
// Set the user's resident organization in the carbon context if user is accessing an organization
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setUserResidentOrganizationId(userResidentOrganization);
if (((AuthenticatedUser) user).isFederatedUser()) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
<org.wso2.carbon.identity.cors.valve.version>${project.version}</org.wso2.carbon.identity.cors.valve.version>

<!--Carbon identity version-->
<identity.framework.version>5.25.652</identity.framework.version>
<identity.framework.version>7.0.46</identity.framework.version>
<carbon.identity.package.import.version.range>[5.17.8, 8.0.0)</carbon.identity.package.import.version.range>

<org.wso2.carbon.identity.oauth.version>6.11.168</org.wso2.carbon.identity.oauth.version>
Expand Down

0 comments on commit 8afedcd

Please sign in to comment.