Skip to content

Pagination not working on GET /Users or /Groups #83

Description

@OutstandingBillNeal

I think there's a design flaw around pagination. The provider implementation in WebHostSample seems to be responsible for pagination (although it does not currently .Skip(), it just .Take()s), but ProviderBase (in SystemForCrossDomainIdentityManagement) is responsible for setting TotalResults. ProviderBase cannot know the correct value for TotalResults if the result it receives from the implementation is already paginated.

The specification says (https://datatracker.ietf.org/doc/html/rfc7644#page-25) that "totalResults [should specify] the total number of results matching the client query". In the example provided by IETF, GET /Users?startIndex=1&count=10 yields

{
  "totalResults":100,
  "itemsPerPage":10,
  "startIndex":1,
  "schemas":["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
  "Resources":[{
    ...
  }]
}

As well as correcting TotalResults, an ideal implementation would also be mindful of efficiency concerns. That might enable the provider to return TotalResults along with the results, so that the implementation can decide whether to use the same query or a different one to ascertain its value.

For example, it might be more efficient to do this

// UserProvider
var results = _db.UserProfiles
    .Where(u => u.ClientId == "xyz")
    .Skip(startIndex)
    .Take(count)
    .Select(some DTO);
var totalResults = _db.UserProfiles
    .Count(u => u.ClientId == "xyz");

than this

// UserProvider
var allResources = _db.UserProfiles
    .Where(u => u.ClientId == "xyz")
    .Select(some DTO);

// ProviderBase
var results = allResources
    .Skip(startIndex)
    .Take(count);
var totalResults = allResources.Count();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions