# add-sso-with-keycloak

Add single sign-on with self-hosted Keycloak (OIDC, PKCE) and verify the discovery document an app depends on

- **Space:** admin-panels-and-internal-tools-public (https://github.com/Tech-Realm/space-admin-panels-and-internal-tools-public/tree/main/add-sso-with-keycloak)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** KC_PG_PASSWORD, KC_ADMIN_PASSWORD
- **Tools:** python3, docker
- **Routes:** keycloak-docker, authentik-docker; checks: 5
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use admin-panels-and-internal-tools-public/add-sso-with-keycloak` or MCP `get_pack admin-panels-and-internal-tools-public/add-sso-with-keycloak`
- **Files:** CHANGELOG.md, code/boot_check.sh, code/compose_lint.py, code/docker-compose.yml, code/oidc_check.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/fixtures/bad-compose.yml, outcome/fixtures/oidc-bad.json, outcome/fixtures/oidc-good.json, outcome/results.json, pack.yaml, refs/refs.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

Add single sign-on with self-hosted Keycloak (OIDC, PKCE) and verify the discovery document an app depends on

## Goal
Our internal tools log in through one IdP with OIDC + PKCE, and an app refuses a misconfigured IdP.

## Steps
1. `bash code/boot_check.sh` -> Keycloak on 127.0.0.1:8084.
2. Create realm `internal`, a client per app (confidential or public+PKCE), roles mapped to our RBAC roles.
3. Check: `oidc_check.py http://127.0.0.1:8084/realms/internal/.well-known/openid-configuration`.
4. Alternatives: Authentik (MIT core, EE flagged), Auth.js (ISC) inside Next.js apps.

## Edge cases
- start-dev is HTTP and in-memory caches: use `start` with hostname + TLS for real use.
- Clock skew breaks token validation: NTP on all hosts.

## Don'ts
- Don't use implicit flow.
- Don't expose the admin console publicly.



---

Canonical URL: https://logicpacks.io/packs/admin-panels-and-internal-tools-public/add-sso-with-keycloak

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
