Skip to content

feat(keycloak): support service account client role mappings#153

Merged
wkulhanek merged 1 commit into
rhpds:mainfrom
evanshortiss:feat/keycloak-service-account-roles
Jun 22, 2026
Merged

feat(keycloak): support service account client role mappings#153
wkulhanek merged 1 commit into
rhpds:mainfrom
evanshortiss:feat/keycloak-service-account-roles

Conversation

@evanshortiss

@evanshortiss evanshortiss commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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:

  ocp4_workload_authentication_keycloak_clients:
  - clientId: backstage-plugin
    secret: "{{ some_secret }}"
    serviceAccountsEnabled: true
    serviceAccountRoles:
      realm-management:
        - query-users
        - view-users
        - query-groups

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>
@evanshortiss evanshortiss force-pushed the feat/keycloak-service-account-roles branch from 723d585 to ecf949b Compare June 19, 2026 08:42
@wkulhanek wkulhanek merged commit ae93422 into rhpds:main Jun 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants