Repository navigation
feat: migrate UI from Keycloak master realm to dedicated kagenti realm - #764
Conversation
pdettori
left a comment
There was a problem hiding this comment.
Review Summary
This PR migrates the Kagenti UI from Keycloak's master realm to a dedicated kagenti realm. The Helm templatization of realm references is clean and the design is well thought out (idempotent, toggle-controlled, backward compatible).
However, the user bootstrap logic silently fails in CI, causing the admin user to not be created in the kagenti realm, which breaks UI login. The pre-commit hooks are also failing on the build job.
Areas reviewed: Python, Helm/K8s, Frontend (TSX)
Commits: 2 commits, all signed-off ✅
CI status: ❌ failing — Deploy & Test (user_not_found in kagenti realm), build 3.12 (pre-commit hooks)
CI Failure Analysis
Deploy & Test: UI E2E agent-chat.spec.ts times out because the Keycloak login fails. Keycloak logs show repeated:
type="LOGIN_ERROR", realmName="kagenti", clientId="kagenti", error="user_not_found", username="admin"
The kagenti realm and client were created, but the admin user was NOT created.
Build (3.12): Fails at "Run pre-commit hooks" step (3.11 was cancelled by matrix strategy).
af0b90f to
e735cdf
Compare
f4a87b3 to
bf7a84f
Compare
|
/run-e2e |
E2E HyperShift Tests FailedCommit: To re-run tests after fixing issues, comment |
New Commits DetectedThe New HEAD: For maintainers: Please review the new changes and comment Security checklistBefore running E2E tests, verify the PR does NOT contain:
This is an automated security measure to prevent TOCTOU attacks |
|
/run-e2e |
E2E HyperShift Tests FailedCommit: To re-run tests after fixing issues, comment |
|
/run-e2e |
E2E HyperShift Tests FailedCommit: To re-run tests after fixing issues, comment |
New Commits DetectedThe New HEAD: For maintainers: Please review the new changes and comment Security checklistBefore running E2E tests, verify the PR does NOT contain:
This is an automated security measure to prevent TOCTOU attacks |
|
/run-e2e |
E2E HyperShift Tests FailedCommit: To re-run tests after fixing issues, comment |
Replace hardcoded `master` realm references with a configurable `kagenti` realm for the Kagenti UI and platform components. This is Phase 1 of aligning all components (UI, AuthBridge demos, CI) onto a single shared Keycloak realm, which will resolve the UI chat 401 issue when AuthBridge is enabled (kagenti-extensions#147). Changes: - values.yaml: change keycloak.realm from `master` to `kagenti`, add `autoBootstrapRealm` toggle - ui.yaml: templatize KEYCLOAK_CONSOLE_URL (was hardcoded /admin/master/) - agent-namespaces.yaml: templatize 4 hardcoded /realms/master references - ui-oauth-secret-job.yaml: pass AUTO_BOOTSTRAP_REALM env var to job - auth_secret.py: add guarded realm bootstrap (create realm + default user if AUTO_BOOTSTRAP_REALM=true and realm != master) - config.py: update fallback realm default from `master` to `kagenti` - AdminPage.tsx: update fallback realm for Keycloak console link The realm bootstrap is idempotent (create-only-if-absent, never resets existing user passwords) and can be disabled for production environments by setting keycloak.autoBootstrapRealm=false in Helm values. Note: AuthBridge demos still use the `demo` realm. UI chat with AuthBridge-protected agents will work once demos are migrated to the `kagenti` realm (Phase 2 follow-up). Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
Newer Keycloak versions (26.x) require email and profile fields for the user account to be considered "fully set up". Without these fields, direct access grants fail with "Account is not fully set up" and the browser login flow may prompt for profile completion. Also grants the realm-admin client role (from realm-management) to the bootstrapped user so they can access the Keycloak admin console for the kagenti realm without a "You do not have permission" error. Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
The Kagenti backend maps the Keycloak 'admin' realm role to kagenti-admin (inheriting kagenti-operator) via a temporary mapping. Without this role in the kagenti realm, users get 403 "Required role(s): kagenti-operator" when using the UI. Create the 'admin' realm role and assign it to the bootstrapped user alongside the existing realm-admin client role. Part of: #767 Signed-off-by: Mariusz Sabath <[email protected]> Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
Address CI failure where user creation silently failed (caught as non-fatal warning), causing downstream user_not_found login errors in the E2E tests. Changes: - Make user creation exception fatal (raise instead of warning) - Add post-creation verification that the bootstrap user exists - Remove redundant change_current_realm() call (constructor already sets realm_name) Addresses review feedback from @pdettori on PR #764. Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
Remove unused imports (Optional, Any) and reformat string concatenations to satisfy ruff-format and ruff-check hooks. Made-with: Cursor Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
The CI E2E tests were failing because the ui-oauth-secret job uses a pre-built quay.io image that lacks the kagenti realm bootstrap logic added in this PR. The user_not_found error in the kagenti realm caused all Playwright login tests to fail. - Add CI script to build the ui-oauth-secret image from source, load it into Kind, and restart the job after the Ansible installer - Add the build step to both e2e-kind-pr and e2e-kind workflows - Change imagePullPolicy to configurable (default IfNotPresent) so Kind uses the locally-loaded image instead of pulling from registry Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
Extend the build script to handle OpenShift by creating a BuildConfig with binary source, building the image inside the cluster, and overriding the Helm values to use the internal registry image. Previously, HyperShift E2E tests used the pre-built quay.io image which lacked PR changes (realm bootstrap, user creation), causing login failures in the kagenti realm. Also adds the build step to both e2e-hypershift-pr.yaml and e2e-hypershift.yaml workflows, placed after Deploy Kagenti and before Pre-flight checks. Signed-off-by: Mariusz Sabath <[email protected]> Made-with: Cursor
597f69f to
37486bb
Compare
New Commits DetectedThe New HEAD: For maintainers: Please review the new changes and comment Security checklistBefore running E2E tests, verify the PR does NOT contain:
This is an automated security measure to prevent TOCTOU attacks |
|
/run-e2e |
E2E HyperShift Tests PassedCommit: The If you push new commits, the label will be removed and you'll need to comment |
The values.yaml pointed to a test image (quay.io/pdettori/ui-oauth-secret) built before PR #764 added realm bootstrap logic. This caused UI login failures on Kind installs because no admin user was created in the kagenti realm. Switch to ghcr.io/kagenti/kagenti/ui-oauth-secret, consistent with agent-oauth-secret and other images. Closes #833 Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The Kagenti platform migrated from the Keycloak "demo" realm to "kagenti" (rossoctl/rossoctl#764). Update the ISSUER and JWKS_URL in .env.authbridge to match, so UI-based tool imports use the correct realm for token validation. Part of: rossoctl/rossoctl#767 Signed-off-by: Mariusz Sabath <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
Summary
masterrealm to a dedicatedkagentirealmauth_secret.py— creates thekagentirealm and a default admin user during installation, controlled byAUTO_BOOTSTRAP_REALM(default:true, setfalsefor prod)realm-adminrole for Keycloak admin console access/realms/masterreferences in Helm templates so all realm URLs derive from{{ .Values.keycloak.realm }}Files changed
charts/kagenti/values.yamlkeycloak.realm: kagenti, addautoBootstrapRealm: truecharts/kagenti/templates/ui.yamlKEYCLOAK_CONSOLE_URLcharts/kagenti/templates/agent-namespaces.yaml/realms/mastercharts/kagenti/templates/ui-oauth-secret-job.yamlAUTO_BOOTSTRAP_REALMenvkagenti/auth/ui-oauth-secret/auth_secret.pykagenti/backend/app/core/config.pykagenti/ui-v2/src/pages/AdminPage.tsxDesign decisions
AUTO_BOOTSTRAP_REALM=falsedisables all privileged Keycloak operations (realm/user creation) for production environmentskeycloak.realm: masterin their values to keep the old behavioruser_realm_name="master"stays in all auth scripts — Keycloak admin API always authenticates throughmaster(Keycloak requirement)realm-adminrole (for admin console access)Known limitations (Phase 1)
demorealm. UI chat with AuthBridge-protected agents will work once demos are migrated to thekagentirealm (Phase 2 follow-up inkagenti-extensions)Test plan
Smoke test checklist
Acceptance criteria
kagentirealm/admin/kagenti/console/AUTO_BOOTSTRAP_REALM=falsewith missing realm shows clear error