Context: I have a custom user federation that implements the getUserById
way. The user id is configured to follow the pattern f:{provider-id}:{external-id}
(as far as I know it’s default id for provider).
I’m calling servers from many clients. Not all of them have provider-id and most likely they shouldn’t have.
Problem: I need to get user by id. It may contain provider-id but it happens that there will be only external-id.
Method used: keycloak.realm(properties.realm).users().get(id).toRepresentation()
I noticed that when only external-id
is used then call does not reach the custom user federation.
There is also statement in docs saying that it iterates over storage providers when user not found:
When a user attempts to log in, Keycloak examines that user’s storage to find that user. If Keycloak does not find the user, Keycloak iterates over each User Storage provider for the realm until it finds a match