CasdoorMarketplace

Keycloak Migration · Provider

Move a Keycloak realm to Casdoor

Export the realm with kc.sh, upload the files to a Casdoor migration and preview what would be added before applying it. Users keep their IDs, which are the sub of their tokens, and sign in with their Keycloak passwords; the clients keep their client IDs and secrets; and the realm's signing key comes along with its key ID, so tokens and the applications that check them keep working.

Verified by CasdoorKeycloakMigrationImport
You need a running Casdoor, self-hosted or on Casdoor Cloud. In the examples, replace https://auth.example.com with your Casdoor address (on Casdoor Cloud, something like https://acme.casdoor.com) and the other example.com addresses with your own.

Set up Keycloak Migration with Casdoor

  1. 1

    Export the realm

    On the Keycloak server, run kc.sh export --dir /tmp/export --realm <realm> --users realm_file. For a realm with many users, --users different_files --users-per-file 5000 writes them into several files, which can all be uploaded together. The partial export of the admin console has no users and hides the client secrets, so use kc.sh.

  2. 2

    Install Keycloak Migration

    On the Marketplace page of Casdoor, install Keycloak Migration into the organization the realm goes to.

  3. 3

    Create the migration

    Under Admin > Migrations, add a migration in that organization, choose Keycloak Migration as the action and upload the export files. If the files have several realms, set the metadata to the realm to import.

    Metadata{"realm": "myrealm"}
  4. 4

    Preview and apply

    Click Preview to see how many certs, groups, applications, users and roles would be added, which exist already and which can't be imported and why, then Apply. Applying again later only adds what is new, and Undo deletes everything the migration added.

  5. 5

    Switch the applications

    Point the applications' issuer, or the discovery URL, at Casdoor. The imported applications sign tokens with the realm's key under its Keycloak key ID and use the standard JWT format, and the identity providers listed in the report have to be added to Casdoor as providers of the applications.

Good to know

  • Users whose Keycloak password uses PBKDF2 or Argon2 sign in with it as before, and Casdoor rehashes it its own way on their first sign-in.
  • Authenticator apps registered in Keycloak keep working, the users don't need to scan a new QR code.
  • Users from an LDAP user federation have no password in the export: add the LDAP server to Casdoor instead.

Keycloak Migration settings are from its documentation as of November 2026 (Keycloak: importing and exporting realms, Keycloak: password hashing). Keycloak Migration is a trademark of its owner.

Frequently asked questions

Does the migration connect to Keycloak?

No. The action only reads the uploaded files, inside Casdoor's sandbox, and sends no requests.

What is not imported?

SAML clients, Keycloak organizations, authorization services, required actions and passkeys. The report lists what was left out.