feat(keycloak): modular client import via post-start pipeline#2
Open
michaelstingl wants to merge 1 commit into
Open
feat(keycloak): modular client import via post-start pipeline#2michaelstingl wants to merge 1 commit into
michaelstingl wants to merge 1 commit into
Conversation
Extract OpenCloud clients (web, Android, iOS, Desktop) from the
monolithic realm JSON into individual files in config/keycloak/clients/.
A numbered post-start pipeline imports them after Keycloak starts:
00-wait-for-keycloak.sh — wait + kcadm.sh authenticate
10-import-clients.sh — partialImport each clients/*.json
11-assign-client-scopes.sh — assign scopes from *.scopes sidecars
Each step is standalone and can be run manually for debugging:
docker exec keycloak /bin/sh /opt/keycloak/bin/10-import-clients.sh
Adding a new OIDC client = drop a .json + .scopes file in clients/.
No realm JSON editing required.
The .scopes sidecar files are a workaround for keycloak#16289
(partialImport ignores defaultClientScopes from client JSONs).
When Keycloak fixes this, the .scopes files and step 11 can be removed.
Changes:
- docker-entrypoint-override.sh: slim orchestrator, forks pipeline
- 00-wait-for-keycloak.sh: wait + authenticate (reusable)
- 10-import-clients.sh: partialImport with {{OC_URL}} resolution
- 11-assign-client-scopes.sh: reads .scopes sidecars, assigns via kcadm.sh
- clients/*.scopes: defaultClientScopes per client (one line, csv)
- opencloud-realm*.dist.json: removed 4 OC clients + roles.client entries
- ldap-keycloak.yml, external-keycloak.yml: mount pipeline scripts + clients/
- README.md: admin & dev guide (adding clients, custom clients via
Compose override, debugging)
- validate-modular-clients.sh: jq-based full realm comparison
(clients, client-scopes, roles, groups, realm settings) against
original monolith — downloads upstream, starts throwaway containers
Tested: both LDAP and autoprovisioning produce identical realms.
Ref: coworking-nuernberg/opencloud-deploy#95
28c1e91 to
c7c53f6
Compare
Owner
Author
Rebased onto upstream/main (2026-05-18)Branch is now on current upstream Notable upstream changes since the original branch point (2026-04-03):
Re-validation post-rebase
PR ready for upstream submission. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extract OpenCloud clients from the monolithic realm JSON into individual files in
config/keycloak/clients/. A numbered post-start pipeline imports them viakcadm.sh partialImportafter Keycloak starts.Adding a new OIDC client = drop a
.json+.scopesfile inclients/. No realm JSON editing required.Post-start pipeline:
00-wait-for-keycloak.sh10-import-clients.shpartialImporteachclients/*.json(SKIP existing)11-assign-client-scopes.sh*.scopessidecarsStep 2 is a workaround for keycloak#16289 (partialImport ignores
defaultClientScopes). Can be removed when Keycloak fixes the issue.Related Issue
Motivation and Context
The two realm
.dist.jsonfiles (LDAP + autoprovisioning) are ~85-95KB monoliths with ~90% overlap. Client definitions are duplicated between the monolith realm JSON and the unusedclients/directory. This PR activates the existingclients/*.jsonfiles and removes the duplicated client definitions from the realm JSONs.Benefits:
clients/, not twice in two realm JSONsdocker execThis uses a zero-dependency shell approach (
kcadm.shships inside the Keycloak container). No extra images or services needed. For larger-scale deployments, keycloak-config-cli is the established alternative.How Has This Been Tested?
clients/directory → worksbash config/keycloak/validate-modular-clients.shdownloads the original upstream realm JSONs from GitHub, starts two containers per variant, exports and diffs withjqTypes of changes
Checklist
config/keycloak/README.md)