Repository navigation
Description
Description
Problem
We need to update existing Keycloak realms using a declarative JSON baseline without affecting any existing users.
Our current deployment uses a realm JSON configuration that contains realm settings, clients, client scopes, protocol mappers, roles, service-account configurations, authentication flows and other realm-level resources.
We want to apply changes to these resources while ensuring that the user database remains completely untouched.
Expected behaviourNon-destructive realm configuration import that completely excludes existing usersntroducing a configuration import/update mode such as:
"--preserve-users=true"
or:
"--exclude-users=true"
Current limitations
- Full realm import with override
Using:
kc.sh import --file=portal-realm.json --override=true
overwrites the existing realm configuration. This is unsuitable for routine configuration updates in an environment containing registered users and runtime-managed data. - Partial import
Using:
kcadm.sh create partialImport -r portal -s ifResourceExists=OVERWRITE -o -f portal-realm.json
supports only a subset of realm resources. It does not provide a complete declarative update mechanism for realm settings, client scopes, authentication flows and other configuration.
Additionally, partial import can affect generated service-account users, as reported in issue #46674. - Admin REST API
Updating all realm configuration through individual Admin REST API calls requires multiple operations and custom orchestration. Authentication flows, their executions and authenticator configurations are particularly difficult to manage as a single consistent configuration.
When enabled, the import should:
- Never create, update or delete existing regular users.
- Never modify user attributes, credentials, required actions or user profile data.
- Never delete or recreate generated service-account users.
- Never modify user sessions or federated user records.
- Continue applying changes to supported realm-level resources, including clients, client scopes, protocol mappers, roles and authentication flows.
- Allow role mappings for service accounts to be updated without recreating the service-account users.
- Preserve all resources not explicitly included in the configuration.
- Support repeated, idempotent execution.
Our use case
We operate approximately 10 independent Keycloak deployments across different regions.
Each deployment uses the same baseline realm configuration, with region-specific values.
When we introduce new clients, client scopes, protocol mappers, roles or authentication-flow changes, we need to roll these changes out across existing realms.
However, these realms already contain registered users and active application environments. Replacing or modifying user data during configuration deployment is unacceptable.
We therefore need a supported way to update realm configuration independently of user data.
Environment
- Keycloak: 26.5.7
- Deployment: Kubernetes
- Deployment mechanism: Helm
- Database: External database
- Configuration: JSON realm baseline
- Markets: Approximately 10 independent deployments
Expected outcome
A supported non-destructive configuration update mechanism that allows us to manage realm configuration as code while guaranteeing that existing user data is excluded from the operation.
The user-preservation behaviour should be explicit, documented and testable.
Discussion
No response
Motivation
No response
Details
No response
Activity
[-]Non-destructive realm configuration import that completely excludes existing users[/-][+]Non-destructive realm configuration import that completely excludes existing users #26.5.7 #[/+]