keycloak / keycloak

Open Source Identity and Access Management For Modern Applications and Services
https://www.keycloak.org
Apache License 2.0
22.33k stars 6.62k forks source link

REST API: Support sorting by specified field #14189

Open Eli-Black-Work opened 2 years ago

Eli-Black-Work commented 2 years ago

Description

The REST API (https://github.com/keycloak/keycloak-community/blob/main/design/rest-api-guideline.md) supports pagination and filtering, but not sorting.

Being able to sort by a column would make pagination more useful, as the user could sort by a non-default column and request only one page of results.

For example, consider a table where a user can click on a column header to sort the table by that column:

Username Email First name Last name
awesomeguy183 joe@example.com Joey Brown
happy_girl Joanna@example.com Joanna Green

When someone clicks the "Last name" column header, the table should be sorted by the last name. The table is divided into several pages of results, because there are many users in the system.

Without being able to sort by the "Last name" field via the REST API, the frontend needs to retrieve the data for all users, and sorting performed via the frontend. This can be quite a bit of data if the Keycloak has a lot of users.

If we could sort via the backend, the frontend would only need to download a small subset of the results 🙂

Discussion

No response

Motivation

No response

Details

No response

JoseOliveira01 commented 1 year ago

It's probably not the best approach but I'm using a microservice called user-management that also addresses this issue. I'm connecting to a secondary data source (keycloak's schema) and sorting the users using my own parameters. However, if this feature came out, I would appreciate it!

inimaz commented 12 months ago

I agree, this feature would be very helpful.

In the meantime, I am doing same as @JoseOliveira01. The problem with this microservice approach is that in order to perform sorting, one has to get the whole list of users in the memory of the microservice and then return the list. This is not scalable if one has lots of users. Plus we cannot use keycloak's pagination.