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

Resolve role sharing conflicts in app sharing #413

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

Conversation

ShanChathusanda93
Copy link
Contributor

@ShanChathusanda93 ShanChathusanda93 commented Nov 12, 2024

Purpose

  • $subject
  • From [1] role management will be enabled in the sub organization level as well.
  • With that, in the sub organization level, there will be two types of roles.
    • Shared roles from the root organization (through the application sharing)
    • Roles created inside the sub organization directly.
  • There can be conflicts when the roles are created in the sub organization level.
  • This PR contains the fixes for the following conflicting scenarios.
    • Sub organization has a role named role01 and an organization audience application will be shared from the root organization and root organization contains a role named role01
      • App sharing will be restricted to that corresponding conflicting sub organization.
    • Sub organization has a role named role01 and already an organization audienace app is shared. Now in the root organization a new organization role will be created with a name role01.
      • Root organization role will not be shared to the conflicting sub organization.
    • Sub organization has a role named role01 and already an organization audienace app is shared. Now in the root organization an existing role is renamed to role01.
      • Role name modification will not be propogated to the conflicting sub organization.

[1] wso2/product-is#21208

Goals

  • Resolving role sharing conflicts.

Approach

  • Restricting the conflicting resource or the main resource that initiated the conflicting resource sharing to the conflicting sub organization

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

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

Project coverage is 28.69%. Comparing base (c30fb79) to head (3e1f647).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ation/management/handler/SharedRoleMgtHandler.java 0.00% 53 Missing ⚠️
...gement/handler/listener/SharedRoleMgtListener.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #413      +/-   ##
============================================
- Coverage     29.01%   28.69%   -0.33%     
  Complexity      385      385              
============================================
  Files            50       50              
  Lines          4146     4193      +47     
  Branches        478      483       +5     
============================================
  Hits           1203     1203              
- Misses         2842     2889      +47     
  Partials        101      101              

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

private static final String ALLOWED_AUDIENCE_FOR_ASSOCIATED_ROLES = "allowedAudienceForAssociatedRoles";
private final ExecutorService executorService = Executors.newFixedThreadPool(5);
public static final String AUDIT_MESSAGE_TEMPLATE = "Initiator : %s | Action : %s | Data : { %s } | Result : %s ";
Copy link
Contributor

Choose a reason for hiding this comment

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

We no longer use this approach to do audit logs
Need to use central logger components audit log publishing

Comment on lines +337 to +338
throw new IdentityEventException(String.format("Role %s already exists in the shared " +
"organization %s.", roleV2.getName(), sharedOrganizationId));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new IdentityEventException(String.format("Role %s already exists in the shared " +
"organization %s.", roleV2.getName(), sharedOrganizationId));
throw new IdentityEventException(String.format("Organization %s has a non shared role with name %s, ", sharedOrganizationId, roleV2.getName()));

@@ -72,6 +76,9 @@ public void handleEvent(Event event) throws IdentityEventException {
case IdentityEventConstants.Event.POST_ADD_ROLE_V2_EVENT:
createSharedRolesOnNewRoleCreation(eventProperties);
break;
case "PRE_SHARE_APPLICATION":
Copy link
Contributor

Choose a reason for hiding this comment

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

Use OrgApplicationMgtConstants defined for this event

@AnuradhaSK
Copy link
Contributor

Add unit tests

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.

2 participants