feat(keycloak): support service account client role mappings#153
Merged
wkulhanek merged 1 commit intoJun 22, 2026
Merged
Conversation
Keycloak automatically creates a service account user when a client has serviceAccountsEnabled=true, but the realm import doesn't assign client roles to it. Add optional serviceAccountRoles dict to keycloak_clients entries — when defined, the realm import includes the service account user with the specified clientRoles mappings. Use case: the RHDH keycloakOrg plugin requires the backstage-plugin service account to have query-users, view-users, and query-groups roles on the realm-management client. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
723d585 to
ecf949b
Compare
wkulhanek
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR adds one optional field (serviceAccountRoles) to the ocp4_workload_authentication_keycloak_clients variable.
Problem
When you create a Keycloak client with serviceAccountsEnabled: true, Keycloak automatically creates a service account user — but the realm import template has no way to assign client roles to it. This matters for plugins like the RHDH keycloakOrg provider, which needs query-users, view-users, and query-groups on the realm-management client.
Change
If a client entry includes a serviceAccountRoles dict, the template adds the service account user to the realm import's users section with the specified clientRoles. If the field isn't defined, behavior is unchanged.
Usage: