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

Get totalResults Value by Total User Count in SCIM2 User API #547

Merged

Conversation

dhaura
Copy link
Contributor

@dhaura dhaura commented Mar 29, 2024

Purpose

  • When the SCIM API is invoked with a filter, the current behavior involves returning a predefined value for the totalResults parameter based on the MaxUserNameListLength, rather than reflecting the actual results that match the filter criteria. This fix addresses the issue by accurately determining the user count that corresponds to the given filter.
  • Furthermore, when invoking user endpoint with groups filter by passing an role (hybrid or system roles), still the endpoint returns a list of userd which a linked to the passed role. But when role group seperation is enabled, it should return an empty list since the passed value is for a role (not for a group). This is also fixed with this PR.
  • To enable these fixes, the following config should be added.
[scim2]
enable_group_based_user_filter_improvements = true

Related Issues

Related PRs

@CLAassistant
Copy link

CLAassistant commented Mar 29, 2024

CLA assistant check
All committers have signed the CLA.

@mpmadhavig
Copy link
Contributor

@dhaura could you please list out all the flows you covered while testing.

Also, if you haven't done already, test this with count query param added in the request.

  • count > 100 -> returned count 100 and totalResults should give the actual amount.
  • count < 100 -> returned count should be the specified amount and totalResults should give the actual amount.

@dhaura
Copy link
Contributor Author

dhaura commented Apr 4, 2024

@mpmadhavig I tested this fix with the SCIM2 user endpoint groups filter using API call [1] for following scenarios.

  • Groups created by organization admin. (ex: Stundet)
    • For 10 and 110 users per group.
  • Hybrid Roles: Administrator, everyone

[1] -

curl --location 'https://<IS_DOMAIN:PORT>/t/<TENANT_DOMAIN>/scim2/Users?filter=groups%2Beq%2BStudent' \
--header 'Authorization: Bearer <TOKEN>'

Also, if you haven't done already, test this with count query param added in the request.

  • count > 100 -> returned count 100 and totalResults should give the actual amount.
  • count = 100
Screenshot 2024-04-04 at 09 35 34
  • count = 105
Screenshot 2024-04-04 at 09 28 47
  • count < 100 -> returned count should be the specified amount and totalResults should give the actual amount.
  • count = 10
Screenshot 2024-04-04 at 09 28 28
  • count = 50
Screenshot 2024-04-04 at 09 28 36

@jenkins-is-staging
Copy link

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

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/8626469299
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/8626469299

@sumedhe sumedhe merged commit 906897b into wso2-extensions:master Apr 15, 2024
3 checks passed
Comment on lines +1451 to +1452
// Get the total user count by the filter query.
// This is only implemented for JDBC userstores.
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 make this a single line comment? Or else format as a multi line comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with #553

@@ -1457,6 +1464,30 @@ private UsersGetResponse filterUsersBySingleAttribute(ExpressionNode node, Map<S
return getDetailedUsers(filteredUsers, totalResults);
}

/**
* method to get user count by filtering parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion : Get user count by filtering parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with #553

@@ -1694,6 +1730,54 @@ private Set<org.wso2.carbon.user.core.common.User> filterUsers(Node node, int of
}
}

/**
* Method to get User Count by Group filter
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion : Get user count by group filter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with #553

Comment on lines +1749 to +1755
String attributeValue = ((ExpressionNode) node).getValue();

/*
If there is a domain and if the domain separator is not found in the attribute value, append the domain
with the domain separator in front of the new attribute value.
*/
attributeValue = UserCoreUtil.addDomainToName(((ExpressionNode) node).getValue(), domainName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the extra assignment in 1749?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with #553

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.

8 participants