How to search for Groups and Roles by their attributes?

Hi,

I’m aware that you can extend Keycloak to expose a search user by custom attributes by using the method org.keycloak.storage.user.UserQueryProvider#searchForUserByUserAttributeStream

I can’t find similar methods for Groups and Roles; how can I search for Groups and Roles with their attributes.

For some added context, we are switch from our own homegrown auth solution and we would like to keep the primary keys when we migrate to Keycloak, since we can’t set our own primary keys in Keycloak, I thought the next best thing is to add the legacy primary keys as attributes in the Users, Groups and Roles entities. That way we can link up our application with Keycloak with these keys.

Any advice is welcomed

Keycloak 18.0.0