Skip to main content

Migrate from Keycloak

This guide covers migrating users, clients, and realm configuration from Keycloak to Idenplane. The migration is performed using Keycloak's realm export JSON format.


Prerequisites​

Before starting the migration:

  • Idenplane installed and running
  • Admin API key configured
  • Keycloak realm export JSON file
  • Sufficient database storage for migrated data
Large Export Files

The import endpoint accepts a JSON request body of up to 10 MB, so a very large export must be split into batches. See Handling Large Exports for details.


Exporting from Keycloak​

Step 1: Generate Realm Export​

In Keycloak Admin Console:

  1. Navigate to your realm
  2. Go to Realm Settings > Action > Partial export
  3. Check Export clients and Export groups and roles
  4. Click Export

Or use the Admin CLI:

${KEYCLOAK_HOME}/bin/kc.sh export \
--realm=your-realm \
--users=realm_file \
--dir=/tmp/exports \
--file=your-realm-export.json

Step 2: Review Export Contents​

The exported JSON contains:

SectionDescription
usersUser accounts with credentials
clientsOAuth 2.0 client applications
rolesRealm and client roles
groupsUser groups with role mappings
identityProvidersSocial/enterprise identity providers (OIDC ones can be imported; see below)
clientScopesOAuth client scopes
Sensitive Data

Exported password hashes depend on Keycloak's password hashing algorithm. See Password Migration for details.

Realm settings​

KeycloakIdenplane
accessTokenLifespanaccessTokenLifespan
ssoSessionMaxLifespanrefreshTokenLifespan (the maximum lifetime of a session)
ssoSessionIdleTimeoutssoSessionIdleTimeout (since 0.12.0; a value under 60 is raised to 60, and an absent or 0 value leaves it off)

Keycloak exports always carry ssoSessionIdleTimeout (30 minutes by default), so an imported realm signs users out after the same idle time as in Keycloak.


Importing to Idenplane​

Basic Import​

Wrap the realm export in a data field. Sending the bare export is rejected with 400:

jq '{data: .}' your-realm-export.json > import.json
curl -X POST "http://localhost:3000/admin/migration/keycloak" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d @import.json

The endpoint needs a global (super-admin) credential. It accepts a JSON body of up to 10 MB (see Request Size Limit), so a larger export has to be split, for example into several files that each carry the realm settings and a slice of users.

Specify Target Realm​

By default, the import creates a realm with the same name as the source. To override:

curl -X POST "http://localhost:3000/admin/migration/keycloak" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"data": '"$(cat your-realm-export.json)"',
"targetRealm": "new-realm-name"
}'

Dry Run Mode​

Test the migration without making changes:

curl -X POST "http://localhost:3000/admin/migration/keycloak" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"data": '"$(cat your-realm-export.json)"',
"dryRun": true
}'

A dry run returns the same report as a real migration but doesn't modify any data.

Request Size Limit​

The import endpoints (POST /admin/migration/keycloak, /auth0, /zitadel, /authentik, and POST /admin/realms/import) accept a JSON body of up to 10 MB. Every other endpoint keeps a 100 KB limit. A larger body is refused with 413 Payload Too Large; split the export into batches (for example 5,000 users each, see the Auth0 guide for a jq recipe) and import them one after the other into the same targetRealm: users that already exist are skipped.


Migration Report​

The migration returns a detailed report:

{
"source": "keycloak",
"dryRun": false,
"startedAt": "2026-11-16T10:00:00.000Z",
"completedAt": "2026-11-16T10:00:04.000Z",
"summary": {
"realms": { "created": 1, "skipped": 0, "failed": 0 },
"users": { "created": 450, "skipped": 12, "failed": 0 },
"clients": { "created": 8, "skipped": 2, "failed": 0 },
"roles": { "created": 25, "skipped": 5, "failed": 0 },
"groups": { "created": 10, "skipped": 0, "failed": 0 },
"scopes": { "created": 0, "skipped": 0, "failed": 0 },
"identityProviders": { "created": 2, "skipped": 0, "failed": 0 }
},
"errors": [
{ "entity": "user", "name": "broken-user", "error": "..." }
],
"warnings": [
{ "entity": "realm", "message": "Realm 'my-realm' already exists, using existing" }
]
}

Response Fields​

FieldTypeDescription
summary.<entity>.creatednumberRows created (in a dry run: rows that would be created)
summary.<entity>.skippednumberRows that already existed and were left unchanged. Keycloak's built-in clients (account, admin-cli, …) are left out and not counted
summary.<entity>.failednumberRows that failed; each has an entry in errors
errors[]array{ entity, name, error } for each failure
warnings[]array{ entity, message } for things that need your attention

A user is skipped when a user with the same username already exists in the target realm. The report does not list which password hashes were carried over; see below.


Password Migration​

Users keep their Keycloak password: Idenplane imports the hash and checks it on sign-in, on the hosted login page and with the password grant alike. On the first successful sign-in the hash is replaced with an Argon2id hash, transparently; the user notices nothing.

The imported password counts as used for the realm's password history (passwordHistoryCount): a user cannot "change" it to the same password, at the first change or the next ones (since 0.13.0).

Supported Algorithms​

Both credential formats of Keycloak exports are read: the current one (Keycloak 7 and later: secretData and credentialData, two JSON strings) and the legacy one (hashedSaltedValue, salt, hashIterations, algorithm on the credential). The algorithm and iteration count recorded in the credential are kept with the hash.

Keycloak algorithmImported as (passwordAlgorithm)Notes
pbkdf2-sha256pbkdf2-sha256Default before Keycloak 24
pbkdf2-sha512pbkdf2-sha512Default in some Keycloak 22-23 and FIPS setups
pbkdf2pbkdf2-sha1Old default (PBKDF2 with HMAC-SHA1)
argon2argon2Default since Keycloak 24; parameters taken from additionalParameters
bcryptbcryptFrom the keycloak-bcrypt extension (the full $2a$/$2b$/$2y$ string)

PBKDF2 hashes are stored as $pbkdf2-<digest>$i=<iterations>,l=<key length>$<salt>$<hash>. A credential with no algorithm (very old exports) is checked against PBKDF2-SHA256, then SHA-512, then SHA-1.

A plaintext value in a credential (allowed by Keycloak's import format) is hashed with Argon2id on import.

Imported before 0.11.0

Before 0.11.0 the importer labelled every Keycloak credential pbkdf2-sha256 and ignored the current credential format, so most migrated users could not sign in. Users imported then are not re-imported (existing usernames are skipped), but their sign-in works after the upgrade: a PBKDF2 hash labelled pbkdf2-sha256 is checked against SHA-256, SHA-512 and SHA-1. Users whose credential was in the current format were imported without a usable hash; delete them and import again, or have them reset their password.

Everything else is imported without a password:

A user whose password used any other algorithm (a custom hash provider, for example) is imported without a password, and the migration report has a warning for them. They must reset their password:

Users without a password​

Users imported without a password must set a new one:

  • the user resets it at /realms/{realm}/forgot-password (the realm needs working e-mail); or
  • an administrator sets one:
curl -X PUT "http://localhost:3000/admin/realms/my-realm/users/${USER_ID}/reset-password" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"password": "<new password>"}'

Check Password Hash Support​

The migration report lists each such user under warnings:

{
"warnings": [
{
"entity": "user",
"message": "User 'legacy': Keycloak password algorithm \"md5-custom\" is not supported; imported without a password (the user must reset it)"
}
]
}
Password Reset Strategy

Tell affected users before the switch, so a password reset e-mail does not surprise them.


Client Migration​

Imported Client Properties​

PropertyMapping
clientIdClient ID
nameClient name
descriptionClient description
redirectUrisValid redirect URIs (see below about wildcards)
webOriginsWeb origins
publicClientPublic client flag
standardFlowEnabledAuthorization code flow
implicitFlowEnabledImplicit flow
directAccessGrantsEnabledDirect access grants

Wildcard redirect URIs​

Keycloak allows redirect URIs ending in /*. Idenplane matches redirect URIs exactly (RFC 9700), so a client imported with such an entry gets allowInsecureWildcardRedirectUris, which keeps the Keycloak behaviour, and the migration report lists it as a warning. That option is insecure: replace the wildcards with the exact callback URLs after the import and turn it off. See Redirect URI matching. A * web origin is not imported.

Built-in Clients​

Keycloak's built-in clients (account, account-console, admin-cli, broker, realm-management, security-admin-console) are left out. They don't appear in the report.

Regenerate Client Secrets​

After migration, regenerate secrets for confidential clients:

curl -X POST "http://localhost:3000/admin/realms/my-realm/clients/${CLIENT_ID}/regenerate-secret" \
-H "x-admin-api-key: ${ADMIN_API_KEY}"

Response:

{
"clientId": "my-app",
"clientSecret": "b3f1c2...64 hex characters...9e0a",
"secretWarning": "Store this secret securely. It will not be shown again."
}

Role Migration​

Role Types​

Keycloak RoleIdenplane Equivalent
Realm rolesRealm roles
Client rolesClient-scoped roles
Composite rolesRole compositions

Default Roles​

Keycloak's built-in realm roles are left out:

KeycloakIdenplane
uma_authorizationNot migrated
offline_accessNot migrated as a role; offline tokens come from the offline_access scope
default-roles-{realm}Not migrated

Composite Roles​

Idenplane has no composite roles. A Keycloak composite role is imported as a plain role, without the roles it contains; assign those roles directly, or through a group.


Group Migration​

Groups are imported by name, with their sub-groups. A group's realmRoles and clientRoles are not imported; assign roles to the groups again after the import.

Group Hierarchy​

Nested groups are preserved in the same structure:

/Engineering
/Backend
/Frontend
/Product
/Design

Handling Large Exports​

Batch Processing​

The import endpoint accepts a JSON body of up to 10 MB; a larger request gets 413, and a very large one may also hit a gateway timeout. For an export above that, or with more than about 5,000 users:

  1. Split the export into several files, each with the realm settings and a slice of users
  2. Import each batch separately
  3. Use the same targetRealm for every batch. Entities that already exist are skipped, so repeating the roles, groups and clients in each batch is harmless

Splitting Users​

# Get total user count
USER_COUNT=$(jq '.users | length' export.json)

# Batches of 5,000 users, each a complete export with a slice of users
jq '.users |= .[0:5000]' export.json > batch1.json
jq '.users |= .[5000:10000]' export.json > batch2.json

Sequential Import​

# Import batch 1
curl -X POST "http://localhost:3000/admin/migration/keycloak" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"data\": $(cat batch1.json), \"targetRealm\": \"my-realm\"}"

# Import batch 2
curl -X POST "http://localhost:3000/admin/migration/keycloak" \
-H "x-admin-api-key: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"data\": $(cat batch2.json), \"targetRealm\": \"my-realm\"}"
Import Order

Import clients, roles, and groups before importing users when splitting the export. This ensures dependencies are resolved correctly.


Post-Migration Steps​

1. Verify User Count​

curl -X GET "http://localhost:3000/admin/realms/my-realm/users?limit=1" \
-H "x-admin-api-key: ${ADMIN_API_KEY}"

2. Test Authentication​

Sign in through the browser login (/realms/{realm}/protocol/openid-connect/auth) with a client you created, using a few migrated users. The password grant checks imported hashes the same way as the login page, and either one moves the hash to Argon2id on the first successful sign-in.

If the realm has a client that allows the password grant, you can also script the check:

async function testMigration(realm: string, testUsers: string[]) {
const results: { user: string; success: boolean }[] = [];

for (const username of testUsers) {
try {
const response = await fetch(
`http://localhost:3000/realms/${realm}/protocol/openid-connect/token`,
{
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
username,
password: 'the-users-password', // placeholder: the user's real password
grant_type: 'password',
client_id: 'my-app', // a client with "password" in its grantTypes
}),
}
);

results.push({ user: username, success: response.ok });
} catch {
results.push({ user: username, success: false });
}
}

return results;
}

3. Update Client Configurations​

Update applications to use Idenplane endpoints:

Keycloak EndpointIdenplane Endpoint
.../auth/realms/{realm}.../realms/{realm}
.../auth/admin/realms/{realm}.../admin/realms/{realm}

4. Check Identity Providers​

The importer creates an identity provider for each entry in identityProviders that the broker can use, with the client ID, secret, endpoints (authorizationUrl, tokenUrl, userInfoUrl, jwksUrl, issuer), default scope, trustEmail and enabled flag from the export. Every other entry is skipped, counted in summary.identityProviders.skipped, and named in warnings with the reason:

  • A Keycloak SAML identity provider (providerId: saml) is imported as a saml provider, with:

    Keycloak (config)Idenplane (samlConfig)
    idpEntityIdentityId (Keycloak's entityId is its own SP entity ID and is not used)
    singleSignOnServiceUrlssoUrl
    postBindingAuthnRequestssoBinding (post when true, else redirect)
    signingCertificate (comma-separated)signingCertificates
    nameIDPolicyFormatnameIdFormat
    wantAuthnRequestsSignedsignAuthnRequests
    wantAssertionsSignedwantAssertionsSigned
    singleLogoutServiceUrlsloUrl (stored only)
    allowedClockSkewclockSkewSeconds (at most 600)
    principalType: ATTRIBUTE + principalAttributesubjectAttribute
    identityProviderMappers of type saml-user-attribute-idp-mapper (attribute.name → user.attribute email, firstName, lastName)attributes

    Idenplane matches SAML attributes by Name. A provider with principalType: FRIENDLY_ATTRIBUTE (users identified by an attribute's FriendlyName), or ATTRIBUTE without principalAttribute, is skipped with a warning rather than imported with the NameID, which would link users to different identities; add it in the console with that attribute's Name as the subject attribute. A mapper that only has attribute.friendly.name is not carried over (warning): the usual attribute names are tried for that field. Mappers to other user attributes are not imported.

    Idenplane always verifies signatures, whatever validateSignature says, so a provider without a usable signing certificate (or without idpEntityId or an SSO URL) is skipped, with every missing or unusable setting named in the warning; add it from the IdP's metadata in the admin console instead. An imported SAML provider gets a warning too: Idenplane has a new SP entity ID and ACS URL, so register its SP metadata (/realms/{realm}/broker/{alias}/saml/metadata) at the IdP before users sign in. Keycloak providers that expected encrypted assertions get a warning: Idenplane does not decrypt them. See Sign in with a SAML identity provider.

  • oidc and keycloak-oidc providers are imported as oidc. google and microsoft (as oidc) and github (as oauth2) get those services' endpoints filled in, since the export has none. Other social providers (gitlab, facebook, linkedin-openid-connect, …) are skipped; add them by hand as oauth2 or oidc providers.

  • An oidc provider without a client ID or an http(s) authorization or token URL is skipped.

  • Keycloak exports secrets as ********** unless told otherwise. A provider without a real secret is imported disabled, with a warning; set the secret and enable it.

  • Imports made before 0.12.0 stored SAML and other providers too. GET /admin/upgrade/health lists them in the identity_provider_types warning (see Providers stored before 0.12.0).

See Identity Providers for the supported types and how to configure one.

5. Notify Users​

Send communications to users about the migration:

  • Migration completion date
  • Password reset requirements (if applicable)
  • New login URL
  • Support contacts

Troubleshooting​

Import Fails with 400 Error​

Cause: Invalid or malformed export JSON.

Solution: Validate the JSON structure:

jq . your-realm-export.json > /dev/null && echo "Valid JSON"

Users Not Migrating​

Cause: User conflicts with existing data.

Solution: Check the migration report for skip reasons and resolve conflicts.

Import Fails with 413​

Cause: The request body is over the 10 MB limit of the import endpoints.

Solution: Split the export into batches. See Request Size Limit.

Passwords Not Preserved​

Cause: Unsupported password hash algorithm (the migration report has a warning for each user).

Solution: Users must complete password reset. See Password Migration.

Missing Roles or Groups​

Cause: A role or group that a user references is missing from the export, or failed to import.

Solution: Check errors in the report. The importer creates roles and groups before users, so they must be in the same export.


API Reference​

POST /admin/migration/keycloak​

Import realm from Keycloak export.

Request:

{
"data": { /* Keycloak realm export JSON */ },
"dryRun": false,
"targetRealm": "my-realm"
}

Parameters:

ParameterTypeRequiredDescription
dataobjectYesKeycloak realm export JSON (body limit 10 MB)
dryRunbooleanNoTest migration without changes (default: false)
targetRealmstringNoOverride target realm name

Response: 200 with the migration report above. 400 for a missing or non-object data, 401 without credentials, 403 for an admin without global scope, 413 for a body over 10 MB.

The same endpoint family also imports Auth0 (/admin/migration/auth0, see Migrating from Auth0), Zitadel (/admin/migration/zitadel) and Authentik (/admin/migration/authentik, see Migrating from Authentik).


Next Steps​

Authentication Guide Learn about OAuth 2.0 and OIDC authentication flows

Authorization Guide Understand RBAC and access control policies

API Reference Complete REST API documentation with examples

React SDK Integrate Idenplane into your React application


idenplane.com · GitHub · Discord