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

Provide SCIM2 roles based outbound provisioning #5893

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

sadilchamishka
Copy link
Contributor

@sadilchamishka sadilchamishka commented Aug 27, 2024

Proposed changes in this pull request

The SCIM2 role based outbound provisioning is provide by this PR.
When role updates, a listener is introduced to be executed to provision the users to the outbound connectors.

Related Issues

The role based outbound provisioning worked for both groups and roles previously. A coma separated role name list is passed in the API payload.

But with IS 7.0, role name is not unique in a given tenant. Hence role uuid is used when referring roles.
The group based outbound provisioning can be separately handled (Adding another column or IDP property to keep the groups for outbound provisioning) instead of having under the list of outbound roles, but in this PR the roles& groups still kept in same list and process.

curl --location --request PUT 'https://localhost:9443/t/<tenant-domain>/api/server/v1/identity-providers/<idp-id>/roles' \
--header 'Accept: application/json' \
--header 'Referer;' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Content-Type: application/json' \
--data '{
    "mappings": [],
    "outboundProvisioningRoles": [
        "<role-uuid>, <group-name>"
    ]
}'

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/10630328699

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/10630328699
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/10630328699

@@ -174,7 +175,16 @@ public boolean doPreSetUserClaimValues(String userName, Map<String, String> inbo
outboundAttributes);

// set the in-bound attribute list.
provisioningEntity.setInboundAttributes(inboundAttributes);
Map<String, String> provisioningAttributes = new HashMap<>(inboundAttributes);
if (IdentityUtil.threadLocalProperties.get().get("newClaimList") instanceof HashMap<?,?>) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Provide appropriate constant.

List<String> roleListOfUser = getUserRoles(userName, tenantDomain);
if (userHasProvisioningRoles(roleListOfUser, provisioningRoleList, userName)) {
List<String> groupListOfUser = getUserGroups(userName, tenantDomain);
groupRoleListOfUser.addAll(groupListOfUser);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Provisioning allowed list contains list of role-uuids and group names
Ex: "2642fb7a-58df-4608-aff9-b90aa73bcc51,group2"

In order to check a matching role or group, the user roles and groups are combined.

@@ -560,13 +561,19 @@ public static boolean isUserTenantBasedOutboundProvisioningEnabled() {
public static boolean isOutboundProvisioningEnabled(String serviceProviderIdentifier,
String tenantDomainName) throws IdentityApplicationManagementException {

if (!isApplicationBasedOutboundProvisioningEnabled()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/* After group role separation, the internal roles should be not be provisioned. Only groups should be
provisioned.
*/
if (isInternalRole(provisioningEntity.getEntityName(), tenantDomain)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a comment saying the entity name can be group name or role-uuid depending on group or role assignment for a user. Hence need to check whether group or role to only allow provisioning groups.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better way to stop role get provisioned.

return;
}
ProvisioningServiceDataHolder.getInstance().getDefaultInboundUserProvisioningListener()
.doPostUpdateUserListOfRole(roleId, deletedUserNames, newUserNames, userStoreManager);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check why this method didn't get invoked in previous way.

@@ -679,7 +690,7 @@ private ProvisioningEntity getInboundProvisioningEntity(ProvisioningEntity provi
IdentityProvisioningConstants.USERNAME_CLAIM_URI, null, null, false),
Arrays.asList(new String[]{userName}));
}
List<String> roleListOfUser = getUserRoles(userName, tenantDomain);
List<String> roleListOfUser = getUserGroups(userName, tenantDomain);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the variable name also accordingly?

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.

3 participants