Repository navigation
feat(auth): generic OIDC issuer and runtime dashboard auth config (#388) - #404
Merged
Merged
Conversation
…livityAI#388) The API validated only Keycloak-issued JWTs (issuer, JWKS path and claims were fixed to the Keycloak layout) and the dashboard baked its Keycloak settings in at build time, so the published image could not be used behind a real domain or with another identity provider. - OIDC_ISSUER switches the API to any OIDC provider (OIDC_JWKS_URI, OIDC_AUDIENCE); with it unset, Keycloak mode is unchanged. One resolver (oidc-config.ts) feeds both verifiers, so HTTP and WebSocket agree. - Claims: roles from realm_access.roles, Zitadel project roles or a flat `roles` array; property scope from property_ids or `property:<uuid>` role keys. In generic mode `*` in the azp allow-list accepts any client (aud stays the boundary). - GET /api/v1/auth/config (public, no secrets) hands the dashboard its login settings; the dashboard loads them before the first render and uses keycloak-js' GenericOidcConfig, falling back to VITE_* values. - users.keycloak_sub becomes text (migration 0032): non-Keycloak subjects are not UUIDs (Zitadel's are numeric). The admin DTO and integration:link accept any OIDC subject. - Cron scripts accept OIDC_TOKEN_URL / OIDC_TOKEN_SCOPE. - Docs: docs/integrations/oidc-generic.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The production image runs only compiled dist/ (no tsx), so the service-principal link step documented for integrations could not run in it. Emit link-integration-principal like run-migrations and seed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The runtime config now carries the property-role prefix, and the dashboard leaves property:<uuid> keys out of the user's roles, as the API already does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Admin create previously allowed any non-empty string up to 255 chars while integration:link enforced printable ASCII via isValidKeycloakSub. Export OIDC_SUB_RE and @matches it on the DTO so both paths agree. Co-authored-by: dusan <dusan@telivity.app>
Match API tokenRoleKeys: when the generic project-roles claim is absent, fall back to urn:zitadel:iam:org:project:<aud>:roles so the UI shows the same roles the API authorizes. Co-authored-by: dusan <dusan@telivity.app>
+8 cases / +2 files from CreateUserDto and tokenRoles specs. Co-authored-by: dusan <dusan@telivity.app>
|
Follow-up hygiene on this branch (additive; author history untouched):
Operator notes:
|
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.
Closes #388.
What this does
HAIP can now run with any OIDC provider (Zitadel, Authentik, Authelia, Entra ID, …) instead of Keycloak, and the published image no longer needs a rebuild per environment: the dashboard reads its login settings from the API at runtime.
With
OIDC_ISSUERunset nothing changes — issuer, JWKS path, claims and theazpallow-list behave exactly as today, and the dashboard keeps its build-timeVITE_*settings.API
oidc-config.ts: one resolver for both verifiers (JwtStrategyandWsAuthService), so HTTP and WebSocket keep agreeing on who may call.OIDC_ISSUER,OIDC_JWKS_URI(required — providers disagree on the path),OIDC_AUDIENCE.*inKEYCLOAK_ALLOWED_AZP/OIDC_ALLOWED_AZPaccepts any client;audstays the boundary. Useful when every integration has its own service account. A literal*in Keycloak mode still names no client.realm_access.roles, Zitadel'surn:zitadel:iam:org:project:roles(or its per-project form), or a flatrolesarray; property scope fromproperty_ids, or from role keysproperty:<uuid>(prefix configurable). Property roles are stripped fromroles.GET /api/v1/auth/config—@Public(), returns only what the browser needs to start a login (issuer, client id, scope) and never a secret.users.keycloak_sub→text(migration0032): non-Keycloak subjects are not UUIDs (Zitadel's are numeric), and the lookup of such asubagainst auuidcolumn was a 500. The adminCreateUserDtoandintegration:linkaccept any OIDC subject (1–255 printable ASCII).packages/database/dist/link-integration-principal.js, so service principals can be linked withoutpnpm/tsx(separate commit).Dashboard
loadAuthConfig()runs before the first render; with anoidcIssuerit builds keycloak-js withGenericOidcConfig({ clientId, oidcProvider }, supported by keycloak-js 26).keycloak/AUTH_ENABLEDstay the same exports (live bindings), soAuthContextandsocket.tsbarely change.Cron
OIDC_TOKEN_URL/OIDC_TOKEN_SCOPEinscripts/cron/_common.sh.Docs
docs/integrations/oidc-generic.md(variables, claims, Zitadel in five steps),.env.example, service-principal and cron READMEs.Tests
oidc-generic.spec.ts(19): config resolution in both modes, claim mapping (Zitadel, Keycloak unchanged, Entra-style), dashboard config without secrets,azpwildcard only in generic mode, and an end-to-endWsAuthService.verifyagainst a local JWKS server (RS256, Zitadel-shaped token with numericsub; wrongaud/iss/azprefused).unauthenticated-routes.spec.ts:/auth/configstays public and secret-free.integration-principal.spec.ts: subjects beyond UUIDs; empty / whitespace / over-long refused.pnpm typecheckandpnpm lintclean (0 errors).node scripts/sync-test-count.mjs, Postgres 16 + Redis 7): 2666 passing across 312 files, 0 failures; README anddocs/test-stats.jsonsynced (+21 tests, +1 file).Verified end to end against Zitadel v4.20.2 (with Login V2): dashboard login through the Zitadel login UI, and service accounts with JWT access tokens calling the staff REST API, scoped by
property:<uuid>roles (403 on other properties).🤖 Generated with Claude Code