3

I am new to this keycloak user management.

Basically I want to fetch users using "IN" condition on username field

venkat.s
  • 120
  • 1
  • 6

2 Answers2

2

Unfortunately, no. See REST API doc: https://www.keycloak.org/docs-api/15.0/rest-api/index.html

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
2

Currently, keycloak doesn't support getting multiple users by ids or usernames.

You can use keycloak SPI:

This is my repo for this query function: Bulk user query

If there is any bug. Feel free to submit pull request too.

cYee
  • 1,915
  • 1
  • 16
  • 24
  • how fast is this. Does keycloak's database make use of an index to query by userId/username or are you performing a full walk of the user table (linear time complexity) – friartuck Jun 15 '23 at 17:19
  • It depends on how fast the query builder execute. This is the link to the code. I didn't give it any benchmark yet. – cYee Jun 18 '23 at 11:24
  • this is the main execution code: https://github.com/imcyee/keycloak-bulk-user/blob/master/providers/rest/src/main/java/org/keycloak/bulkuser/rest/BulkuserResourceProvider.java – cYee Jun 18 '23 at 14:59
  • how is keycloak database indexed? is it not designed for doing bulk user operations? e.g. find users by some specific attribute(s) without doing a full table walk. – friartuck Jun 19 '23 at 15:20
  • I think it is probably a feature that is not in the priority list. I see similar functionality in Auth0. I believe they should have it indexed at least for the user id field, but i didnt check it. My usecase volume is not yet require optimization yet. – cYee Jun 22 '23 at 10:45