Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set parent user's user store domain in shared token revoke flow #2664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HasiniSama
Copy link
Contributor

@HasiniSama HasiniSama commented Jan 7, 2025

Proposed changes in this pull request

Purpose

When revoking an access token in a shared user flow, the authorized user's User Store Domain is set to the shared user's domain. Therefore, when retrieving the clientIDs from here, it will only retrieve the clientIDs associated with the shared user's User Store Domain.

However, when creating access tokens for shared users the User Store Domain of the parent user is used here and here. Hence these tokens are not getting revoked.

Approach

Hence the access token revoke logic for shared user flow has to be improved to handle the user's domain correctly which will eventually detect all the clientIDs issued.

This is an alternative approach to the fix wso2-extensions/identity-oauth2-grant-organization-switch#38. In which we amend the user store domain when the token is issued. Which would lead to user store mismatch between the token and the actual user. Here, we change the logic in the token revoke method.

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 55.77%. Comparing base (c14d5ef) to head (87b1244).
Report is 74 commits behind head on master.

Files with missing lines Patch % Lines
...java/org/wso2/carbon/identity/oauth/OAuthUtil.java 0.00% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2664      +/-   ##
============================================
+ Coverage     55.48%   55.77%   +0.28%     
+ Complexity     8536     8416     -120     
============================================
  Files           632      632              
  Lines         49870    48515    -1355     
  Branches       9295     8965     -330     
============================================
- Hits          27672    27058     -614     
+ Misses        18254    17612     -642     
+ Partials       3944     3845      -99     
Flag Coverage Δ
unit 38.93% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +1357 to +1358
String parentUserId = OAuthComponentServiceHolder.getInstance().getOrganizationUserSharingService()
.getUserAssociation(userId, accessingOrgId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of returning null from getUserAssociation(...) ? If yes, do a null check to avoid NPE

Comment on lines +751 to +753
Optional<String> parentUserStoreDomain = getUserStoreDomainOfParentUser(
userId, accessingOrg, tenantDomain);
parentUserStoreDomain.ifPresent(authenticatedUser::setUserStoreDomain);
Copy link
Contributor

@sadilchamishka sadilchamishka Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part may need to move to a else block under below if block.
Shall we try the flow for sub-org and another level of sub-org. No need to add a user store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants