8000 Importing realm via Keycloak Operator does not give users the default realm roles · Issue #44778 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Importing realm via Keycloak Operator does not give users the default realm roles #44778

Closed

Description

@bartvanb

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

import-export

Describe the bug

I am importing a realm with the keycloak operator as described in the docs. In this realm import, I also specified which users should be created, see the admin user in this yaml:

apiVersion: k8s.keycloak.org/v2alpha1
kind: KeycloakRealmImport
metadata:
  labels:
    app: auth
  name: vantage6-auth-realm-import
  namespace: default
spec:                                                                                                                                      │
  keycloakCRName: test-auth-kc
  realm: test-realm
  users:
      username: admin
      credentials:
      - type: password
        value: my-super-secret-admin-password

As expected, the realm and the user are created. However, I ran into this issue that the user is not given have the default realm roles. I.e. if I go to the admin UI -> go to new realm -> users -> user created via realm import -> role mapping, this is empty. I'd expect to see a role default-roles-<realm-name>

Any subsequent user that I create in the realm is given the default-roles-<realm-name> as expected.

Could it be that the user is created before the default realm role and therefore does not receive it?

Workaround

My temp workaround is to just assign the rules directly to the user in my realm config:

...
  users:
    - username: admin
      ...
      clientRoles:
        account:
          - manage-account
          - view-profile

Version

26.4.7

Regression

  • The issue is a regression

Expected behavior

Users defined in the realm import get the default realm roles

Actual behavior

Users defined in realm import get no permissions whatsoever (unless explicitly specified)

How to Reproduce?

Use above yaml for a keycloak realm import using the keycloak operator (see getting start docs -> operator.

Anything else?

No response

Activity

  1. added theissue type on Dec 9, 2025
  2. locked and limited conversation to collaborators on Dec 9, 2025
  3. converted this issue into a discussion #44782 on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/import-exportRealm import and export — JSON files, partial import, CLI importkind/bugCategorizes a PR related to a bugteam/core-shared

    Type

    Fields

    No fields configured for bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0