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 dc7e392 commit 441b8e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3117,7 +3117,7 @@ public Set<AccessTokenDO> getAccessTokensByBindingRef(String bindingRef) throws
}
/* Tenant domain of the application is set as the authenticated user tenant domain for the
organization SSO login users. */
if (user.isOrganizationSSOUser()) {
if (user.isOrganizationUser()) {
user.setTenantDomain(OAuth2Util.getTenantDomain(IdentityTenantUtil.getLoginTenantId()));
}
Timestamp issuedTime = resultSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public RefreshTokenValidationDataDO validateRefreshToken(String consumerKey, Str
}
/* Tenant domain of the application is set as the authenticated user tenant domain for the
organization SSO login users. */
if (user.isOrganizationSSOUser()) {
if (user.isOrganizationUser()) {
user.setTenantDomain(IdentityTenantUtil.getTenantDomainFromContext());
}
validationDataDO.setAuthorizedUser(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private Map<String, Object> getUserClaimsInOIDCDialect(OAuthTokenReqMessageConte
// Map<(http://wso2.org/claims/email, email), "[email protected]">
Map<ClaimMapping, String> userAttributes = getCachedUserAttributes(requestMsgCtx);
if (userAttributes.isEmpty() && (isLocalUser(requestMsgCtx.getAuthorizedUser())
|| isOrganizationSsoUserSwitchingOrganization(requestMsgCtx.getAuthorizedUser()))) {
|| isOrganizationUserSwitchingOrganization(requestMsgCtx.getAuthorizedUser()))) {
if (log.isDebugEnabled()) {
log.debug("User attributes not found in cache against the access token or authorization code. " +
"Retrieving claims for local user: " + requestMsgCtx.getAuthorizedUser() + " from userstore.");
Expand Down Expand Up @@ -657,16 +657,16 @@ private Map<String, String> getUserClaimsInLocalDialect(String username,
}

/**
* Check whether an organization SSO user is trying to switch the organization.
* Check whether a user managed by an organization is trying to switch to another organization.
*
* @param authorizedUser authorized user from the token request.
* @return true if an organization SSO user is trying to switch the organization.
* @return true if an organization user is trying to switch to another organization.
*/
private boolean isOrganizationSsoUserSwitchingOrganization(AuthenticatedUser authorizedUser) {
private boolean isOrganizationUserSwitchingOrganization(AuthenticatedUser authorizedUser) {

/* When accessing organization is different to the resident organization, it means the user is trying to switch
the organization. */
return authorizedUser.isOrganizationSSOUser() &&
/* For an organization user, when accessing organization is different to the resident organization,
it means the user is trying to switch to different organization. */
return authorizedUser.isOrganizationUser() &&
!authorizedUser.getUserResidentOrganization().equals(authorizedUser.getAccessingOrganization());
}

Expand Down

0 comments on commit 441b8e9

Please sign in to comment.