I’m developing an application in which login and roles are entirely handled by Keycloak. My Java backend has an application database that also contains additional user business data. I’ve been asked to retrieve all users registered in the application based on their roles. The problem is that only Keycloak knows the roles, while I normally handle pagination on the database side.
What would be the best practice to efficiently achieve this goal?
Currently, I'm loading all user data from the database (filtering by other parameters I have in the DB, though it could be all of them), mapping their roles one by one, removing the roles I'm not interested in, and then paginating the remaining users.

2 Replies 2

Maybe invert that approach:

I was probably not specific enough in describing the problem. They might also want to filter by properties that are not roles but business-related attributes. The issue is that the filtering criteria could be a mix of business data and Keycloak data.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.