Skip to content

fix keycloak implementation and install.sh script and add manager fixes - #508

Merged
rolandpickl merged 4 commits into
mainfrom
keycloak-installer-fix
Jun 3, 2026
Merged

fix keycloak implementation and install.sh script and add manager fixes#508
rolandpickl merged 4 commits into
mainfrom
keycloak-installer-fix

Conversation

@rolandpickl

@rolandpickl rolandpickl commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

I have fixed the install.sh script, so that it no longer breaks
Also fixed is the keycloak configuration on install. Now when installing, keycloak fully works.
There were changes in the EDDI-Manager necessary, those changes also have been added.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • ♻️ Refactoring (no functional changes)
  • 🔧 Chore (dependency updates, CI changes, etc.)

Related Issue

Closes #

Changes Made

  • install.sh -> now works for linux and mac
  • keycloak configuration is fixed and works out of the box, when installing on local
  • Manager fixes that where necessary on auth were imported into EDDI main

How to Test

  1. run install.sh --local
  2. select keycloak on
  3. login with eddi/eddi and see that it is working

Checklist

  • My code follows the project's code style
  • I have added tests that prove my fix/feature works
  • Existing tests pass locally (./mvnw clean verify -DskipITs)
  • I have updated documentation if needed
  • My commit messages follow conventional commits
  • I have not committed any secrets, API keys, or tokens
  • This PR has a clear, focused scope (one concern per PR)

Summary by CodeRabbit

  • New Features

    • Added an authentication configuration endpoint and switched the manager UI to a SPA shell.
  • Authentication

    • Installer now auto-configures Keycloak client settings during setup (non-fatal warnings on partial failures).
    • Keycloak realm seed updated with default roles and expanded localhost origin/redirect allowlist.
    • Service advertises a browser-reachable Keycloak URL with configurable external port.
  • Security

    • Content Security Policy extended to permit Keycloak connections and updated OIDC issuer handling.

@rolandpickl
rolandpickl requested a review from ginccc as a code owner June 2, 2026 19:08
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Keycloak OIDC runtime wiring, patches the Keycloak client post-startup, exposes a backend JS auth-config endpoint, replaces the frontend with a SPA that loads the auth config, updates CSP and static-asset allowlists, and refreshes frontend build artifacts.

Changes

Keycloak OIDC Integration & Frontend SPA

Layer / File(s) Summary
Docker Compose OIDC Infrastructure
docker-compose.auth.yml
EDDI and Keycloak services now configure public-facing hostnames and explicit token issuer overrides while keeping internal OIDC discovery for backend interactions.
Keycloak Realm & Role Configuration
keycloak/eddi-realm.json
Adds a composite default role, explicit localhost webOrigins for frontend dev ports, includes openid client scope, backend audience protocol mapper, and adds first/last name to seeded users.
Installation Script & Keycloak Client Configuration
install.sh
Wizard selections use explicit if-blocks; new configure_keycloak_client() waits for Keycloak, obtains admin token, finds eddi-frontend client, patches webOrigins/redirectUris, PUTs the client, logs warnings on failure, and is invoked during startup.
Backend Auth Configuration Endpoint
src/main/java/ai/labs/eddi/ui/IRestManagerResource.java, src/main/java/ai/labs/eddi/ui/RestManagerResource.java
New GET /manage/__auth_config__.js endpoint returns window.__EDDI_AUTH__ JS, emitting "none" when OIDC is disabled or a Keycloak config with public URL, parsed realm, and fixed eddi-frontend clientId; includes JS-escaping helpers and no-cache headers.
Frontend SPA Shell & Auth Config Integration
src/main/resources/META-INF/resources/index.html, src/main/resources/META-INF/resources/manage.html
index.html replaced by a SPA entrypoint loading /manage/__auth_config__.js and versioned assets; manage.html updated to reference the auth config script, new asset hashes, and uses system-ui font stack for the loader.
Content Security Policy & Static Asset Authorization
src/main/resources/application.properties
CSP connect-src now allows Keycloak via ${eddi.keycloak.public.url:}; static-assets allowlist expanded with SPA/manage/chat paths and explicit top-level icon/asset files.
Frontend Build Artifact Module Dependencies
src/main/resources/META-INF/resources/assets/{cssMode,freemarker2,handlebars,html,htmlMode,javascript,jsonMode,liquid,lspLanguageFeatures,mdx,python,razor,tsMode,typescript,xml,yaml}-*.js
Multiple language-mode and editor bundles update hashed import specifiers while preserving exported configurations; LSP language-features bundle adjusts newline/CRLF line offset handling.

Sequence Diagram

sequenceDiagram
  participant Browser
  participant EDDI
  participant Keycloak
  Browser->>EDDI: GET /manage/__auth_config__.js
  EDDI->>Keycloak: (server) use internal QUARKUS_OIDC_AUTH_SERVER_URL for discovery
  EDDI-->>Browser: serve JS setting window.__EDDI_AUTH__ (method none or keycloak + realm + clientId + url)
  Browser->>Keycloak: browser auth flows -> KC_HOSTNAME (public)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I hopped through realms to set the gate,
I patched CORS so local ports relate,
A JS whisper tells the SPA how to start,
The index woke and played its authful part,
Builds refreshed — the meadow hums, restart.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.66% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title mentions three distinct areas (keycloak implementation, install.sh script, manager fixes) but is somewhat vague about what specific problems are being fixed. It lacks clarity on the primary change. Consider a more specific title that highlights the main objective, such as 'Fix Keycloak configuration and installer script for local installations' to make the primary focus clearer.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch keycloak-installer-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker-compose.auth.yml`:
- Around line 21-31: The docker compose uses ${KEYCLOAK_PORT} in
EDDI_KEYCLOAK_PUBLIC_URL, QUARKUS_OIDC_TOKEN_ISSUER and KC_HOSTNAME but the
keycloak service still publishes a fixed 8180:8080, so overrides of
KEYCLOAK_PORT will break discovery; fix by making the keycloak service's
published port use the same variable (e.g., change the service port mapping to
"${KEYCLOAK_PORT:-8180}:8080") or alternatively define KEYCLOAK_PORT with a
default in the compose environment and reference that consistently so
EDDI_KEYCLOAK_PUBLIC_URL, QUARKUS_OIDC_TOKEN_ISSUER and KC_HOSTNAME remain
aligned with the actual published port.

In `@install.sh`:
- Around line 823-831: The https_origin is incorrectly constructed from
EDDI_PORT causing Keycloak to be updated with the HTTP port; change the
https_origin construction to use EDDI_HTTPS_PORT instead of EDDI_PORT so the PUT
request that updates the client (see variables https_origin, http_origin and the
curl that sets update_status for client_uuid at kc_base using admin_token)
includes the actual HTTPS origin (e.g., "https://localhost:${EDDI_HTTPS_PORT}")
and then leave the rest of the payload unchanged so redirectUris/webOrigins
include the correct secure origin.

In `@keycloak/eddi-realm.json`:
- Line 140: The seeded user credentials in eddi-realm.json are marked
"temporary": false making demo passwords permanent; change the "temporary"
property to true for the seeded accounts (the entries for usernames eddi,
viewer, and user) so their initial passwords require rotation on first login;
locate the credential objects in eddi-realm.json (the credential blocks
associated with the eddi/eddi, viewer/viewer, and user/user user records) and
update "temporary": false → "temporary": true for each.
- Around line 84-91: eddi-frontend.webOrigins is missing the installer's default
HTTPS origin; add "https://localhost:7443" to the eddi-frontend client
"webOrigins" array so the Keycloak client allows the Manager served on the
documented HTTPS port (update the eddi-frontend.webOrigins list to include that
origin alongside the existing localhost entries).

In `@src/main/java/ai/labs/eddi/ui/RestManagerResource.java`:
- Around line 120-128: extractRealm currently returns the realm with any
trailing path delimiter (e.g., "eddi/") when authServerUrl ends with a slash;
update extractRealm to trim trailing slashes (and other path delimiters if
applicable) from the extracted realm before returning it: after computing the
realm substring and removing the query portion (in extractRealm), strip any
trailing '/' characters (and whitespace) so the method returns "eddi" instead of
"eddi/"; ensure this is applied in both the branch where "/realms/" is found
(variable realm) and the fallback return for non-null authServerUrl.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8085051b-3dea-4282-a664-d28b0546b37f

📥 Commits

Reviewing files that changed from the base of the PR and between b136419 and 0ec6cb4.

⛔ Files ignored due to path filters (2)
  • src/main/resources/META-INF/resources/eddi-icon.ico is excluded by !**/*.ico
  • src/main/resources/META-INF/resources/eddi-icon.svg is excluded by !**/*.svg
📒 Files selected for processing (27)
  • docker-compose.auth.yml
  • install.sh
  • keycloak/eddi-realm.json
  • src/main/java/ai/labs/eddi/ui/IRestManagerResource.java
  • src/main/java/ai/labs/eddi/ui/RestManagerResource.java
  • src/main/resources/META-INF/resources/assets/cssMode-C5TT1L4e.js
  • src/main/resources/META-INF/resources/assets/freemarker2-DCGWkmiA.js
  • src/main/resources/META-INF/resources/assets/handlebars-u2Ap1EnQ.js
  • src/main/resources/META-INF/resources/assets/html-CRclPP81.js
  • src/main/resources/META-INF/resources/assets/htmlMode-Bg0c_U0Q.js
  • src/main/resources/META-INF/resources/assets/index-9Ly7lA6T.css
  • src/main/resources/META-INF/resources/assets/index-BZNayFGO.css
  • src/main/resources/META-INF/resources/assets/index-Bn-sgAam.js
  • src/main/resources/META-INF/resources/assets/javascript-BD21fPfT.js
  • src/main/resources/META-INF/resources/assets/jsonMode-DnyOtT0_.js
  • src/main/resources/META-INF/resources/assets/liquid-V64DwArz.js
  • src/main/resources/META-INF/resources/assets/lspLanguageFeatures-DCTAZVps.js
  • src/main/resources/META-INF/resources/assets/mdx-BtMCnFzF.js
  • src/main/resources/META-INF/resources/assets/python-DEWDJFn1.js
  • src/main/resources/META-INF/resources/assets/razor-DfQnovyn.js
  • src/main/resources/META-INF/resources/assets/tsMode-Dc3VVqFA.js
  • src/main/resources/META-INF/resources/assets/typescript-LWRzWAn4.js
  • src/main/resources/META-INF/resources/assets/xml-GW7RS4i4.js
  • src/main/resources/META-INF/resources/assets/yaml-V0todZvQ.js
  • src/main/resources/META-INF/resources/index.html
  • src/main/resources/META-INF/resources/manage.html
  • src/main/resources/application.properties

Comment thread docker-compose.auth.yml
Comment thread install.sh Outdated
Comment thread keycloak/eddi-realm.json
Comment thread keycloak/eddi-realm.json Outdated
Comment thread src/main/java/ai/labs/eddi/ui/RestManagerResource.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates EDDI’s local install/authentication story by wiring the Manager SPA to a runtime-provided Keycloak/OIDC configuration, adjusting HTTP security headers, updating the Keycloak realm export, and adding post-start Keycloak client configuration to the installer.

Changes:

  • Add a /manage/__auth_config__.js endpoint and update the Manager HTML shell to consume runtime Keycloak/OIDC settings.
  • Update CSP and unauthenticated static-asset allowlist to support Keycloak connectivity and new root-level icons/assets.
  • Enhance install.sh and the auth compose overlay to configure Keycloak more reliably for local development.

Reviewed changes

Copilot reviewed 24 out of 29 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/main/resources/META-INF/resources/manage.html Loads runtime auth config script and updates asset references/favicon.
src/main/resources/META-INF/resources/index.html Converts root entry to SPA shell and updates asset references/favicon.
src/main/resources/META-INF/resources/eddi-icon.svg Adds new SVG app icon.
src/main/resources/META-INF/resources/assets/yaml-V0todZvQ.js Repoints YAML mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/xml-GW7RS4i4.js Repoints XML mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/typescript-LWRzWAn4.js Repoints TS mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/tsMode-Dc3VVqFA.js Repoints TS worker mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/razor-DfQnovyn.js Repoints Razor mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/python-DEWDJFn1.js Repoints Python mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/mdx-BtMCnFzF.js Repoints MDX mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/lspLanguageFeatures-DCTAZVps.js Updates LSP language features bundle reference used by other modes.
src/main/resources/META-INF/resources/assets/liquid-V64DwArz.js Repoints Liquid mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/jsonMode-DnyOtT0_.js Updates JSON mode to import the updated LSP bundle and main bundle.
src/main/resources/META-INF/resources/assets/javascript-BD21fPfT.js Repoints JS mode to updated TS mode and main bundle.
src/main/resources/META-INF/resources/assets/htmlMode-Bg0c_U0Q.js Updates HTML mode to import updated LSP bundle and main bundle.
src/main/resources/META-INF/resources/assets/html-CRclPP81.js Repoints HTML language definition bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/handlebars-u2Ap1EnQ.js Repoints Handlebars mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/freemarker2-DCGWkmiA.js Repoints FreeMarker mode bundle imports to new hashed main bundle.
src/main/resources/META-INF/resources/assets/cssMode-C5TT1L4e.js Updates CSS mode to import updated LSP bundle and main bundle.
src/main/resources/application.properties Updates CSP connect-src to include Keycloak public URL and expands static asset permit paths.
src/main/java/ai/labs/eddi/ui/RestManagerResource.java Implements runtime auth config JS endpoint and Keycloak config derivation.
src/main/java/ai/labs/eddi/ui/IRestManagerResource.java Adds JAX-RS endpoint contract for /manage/__auth_config__.js.
keycloak/eddi-realm.json Updates realm export with default roles/scopes, CORS origins, audience mapper, and user fields.
install.sh Adds post-start Keycloak client configuration and tweaks wizard boolean setting.
docker-compose.auth.yml Adds public Keycloak URL env var and Keycloak hostname/backchannel settings for issuer correctness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/resources/META-INF/resources/index.html
Comment thread src/main/java/ai/labs/eddi/ui/RestManagerResource.java Outdated
Comment thread src/main/java/ai/labs/eddi/ui/RestManagerResource.java
Comment thread docker-compose.auth.yml
Comment thread install.sh Outdated
Comment thread install.sh
Comment thread install.sh
Comment thread install.sh
rolandpickl and others added 2 commits June 3, 2026 12:34
- docker-compose.auth.yml: use ${KEYCLOAK_PORT:-8180}:8080 for keycloak
  port mapping so overriding KEYCLOAK_PORT stays consistent end-to-end
- keycloak/eddi-realm.json: add https://localhost:7443 to webOrigins;
  set temporary:true for all seeded users (eddi, viewer, user) so demo
  passwords require rotation on first login
- RestManagerResource.java: fix extractRealm() to strip trailing /,  ?,
  and # delimiters; fix escapeJs() to also escape \n, \r, \t to prevent
  JS injection via newlines in config values
- index.html: load /manage/__auth_config__.js so window.__EDDI_AUTH__ is
  populated at root /; update asset refs to index-NTxUCPZ1.js /
  index-CJdl8JdC.css (old files no longer exist)
- install.sh: remove unused eddi_origin variable; prefer jq for JSON
  parsing with python3 as fallback (warn and skip if neither available);
  fix https_origin to use EDDI_HTTPS_PORT instead of EDDI_PORT; add
  https_origin/* to redirectUris; GET-then-PUT full ClientRepresentation
  to avoid wiping Keycloak client settings on partial update

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/META-INF/resources/index.html`:
- Around line 10-11: index.html currently references hashed bundles (script src
"/assets/index-NTxUCPZ1.js" and stylesheet href "/assets/index-CJdl8JdC.css")
that differ from the ones used by manage.html, causing potential 404s; update
the asset references in index.html to match the exact hashed filenames used in
manage.html (or switch both entrypoints to the same template/manifest-driven
asset names used by your build system) by editing the <script> and <link>
entries so both index.html and manage.html point to the identical generated
bundle names.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc42e00b-0495-4736-80a2-7447dd075f1c

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec6cb4 and 6089324.

📒 Files selected for processing (5)
  • docker-compose.auth.yml
  • install.sh
  • keycloak/eddi-realm.json
  • src/main/java/ai/labs/eddi/ui/RestManagerResource.java
  • src/main/resources/META-INF/resources/index.html
🚧 Files skipped from review as they are similar to previous changes (3)
  • docker-compose.auth.yml
  • install.sh
  • src/main/java/ai/labs/eddi/ui/RestManagerResource.java

Comment thread src/main/resources/META-INF/resources/index.html Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/META-INF/resources/index.html`:
- Around line 13-14: Add the same pre-mount loader from manage.html to
index.html so users see the branded spinner/logo before React mounts: copy the
loader CSS into the <head> (styles that target the loader classes) and replace
or populate the existing <div id="root"> element with the loader HTML markup
used in manage.html (the logo and spinner wrapper), ensuring class names and IDs
match those styles so the loader displays immediately and is removed/overridden
when React mounts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24b0b2e9-27f5-4844-926e-7de5d0a88ec5

📥 Commits

Reviewing files that changed from the base of the PR and between 6089324 and d4ecf8b.

📒 Files selected for processing (1)
  • src/main/resources/META-INF/resources/index.html

Comment thread src/main/resources/META-INF/resources/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants