Skip to main content

Plan: Epinio's Dex connector against this platform's identity providers

IMPLEMENTATION RULES: Before implementing this plan, read and follow:

Status: Verified live end to end for the Authentik connector on BOTH platforms — Rancher Desktop (urb-agents#2056, #2057, 1.6.258) and Proxmox (urb-agents#2058, 1.6.260): real sign-in, a real epinio login token exchange, push, deploy, expose, and a user outside any mapped group correctly walled off. Okta is out of scope for now (needs a real tenant). GitHub connector verified short of browser login.​

Goal: wire Epinio's own bundled Dex to up to three identity providers (GitHub, Authentik, Okta), each mapping its own groups/teams to namespace roles, instead of Epinio's default basic auth. Referenced by name in 625-setup-epinio.yml since that playbook first shipped — this is the piece it always deferred.

Migration source: urb-agents#1909/#1911's Epinio PoC on a lab test cluster — gates 17 (GitHub) and 18 (Authentik, Okta), proven live there. Full gate-by-gate record: INVESTIGATE-host-epinio-rollout.md in terchris/home. Migrated via urb-agents#2040.

Related: PLAN-service-epinio-001-install, PLAN-service-epinio-004-object-storage

Created: 2026-10-27


Generalized from one hardcoded setup into real parameters​

The PoC proved this against one specific GitHub org/teams and one specific Authentik install's groups. None of that — org name, team names, group names, role mappings — is generic UIS config; it is one install's own identity structure. Nothing from the PoC's real values is committed here: each connector is enabled: false by default, and an operator supplies the real structure via -e @vars-file.yml (the nested shape does not fit flat -e k=v pairs). Only the OAuth client secrets go through the normal secrets pipeline (EPINIO_DEX_GITHUB_CLIENT_SECRET etc.) — client IDs are not secret (GitHub's own OAuth spec treats them as public) and are ordinary playbook vars instead.

The five Dex gotchas, found live during the PoC, baked in rather than left to be rediscovered​

  1. dex.connectors[].config.scopes replaces the default set, not adds — profile/ email are listed explicitly alongside groups in every connector, or Dex's callback fails on a missing name claim.
  2. A generic oidc connector needs insecureEnableGroups: true before any groups claim is parsed at all, even when the scope is granted and present.
  3. Dex only reads its connector config (a Secret, mounted as a volume) at startup — a Helm values change needs an explicit kubectl rollout restart deployment/dex after, every time. 627-setup-epinio-identity.yml's own restart task is unconditional, not gated on "did the config actually change" — confirmed live that a config change with no restart leaves the OLD connector list serving.
  4. Okta's default authorization server sends no email_verified claim at all — insecureSkipEmailVerified: true on that connector only.
  5. admin:<namespace> alone is not enough — Epinio's own API returns 403 on every call, including a bare namespace list, unless a bare "user" role is also granted. Every group in every connector gets user alongside whatever admin:<ns> roles it maps to.

The one genuinely new platform capability this needed: cross-namespace trust​

Dex runs in the epinio namespace; Authentik's own TLS certificate (already real, urb-agents#1917 bug #570) lives in the authentik namespace. Kubernetes Secrets cannot cross namespaces on their own. New UIS service: reflector (emberstack/kubernetes-reflector, Helm chart version 9.1.9, confirmed live against the chart's own repo index 2026-10-27) — mirrors an annotated Secret into other namespaces, kept in sync automatically on every renewal. 627-setup-epinio-identity.yml patches Authentik's existing Certificate with the reflection annotations (only when the authentik connector is enabled), reading the Certificate's current annotations first and unioning the target namespace list rather than overwriting it — a second future consumer of the same Certificate must not have its own namespace silently dropped by this playbook re-running.

What was built​

  • provision-host/uis/services/management/service-reflector.sh + ansible/playbooks/028-setup-reflector.yml / 028-remove-reflector.yml — the new service, modeled directly on service-external-secrets.sh's shape. Remove refuses if anything is still annotated for reflection, same precedent as external-secrets' own ClusterSecretStore check.
  • ansible/playbooks/627-setup-epinio-identity.yml — validates each enabled connector's required fields and secret; when authentik is enabled, patches Authentik's Certificate (union, not overwrite), waits for the mirrored Secret to actually land, renders and merges the Epinio OAuth2/OIDC blueprint into the existing app-slot1 expansion slot (reusing the exact mechanism 073-authentik-3-app-slot1-blueprint.yaml already provides, the same way service-authentik-epinio-provider.yml did during the PoC); renders manifests/627-epinio-identity-values.yaml.j2 and applies it with helm upgrade --reuse-values (merges on top of 625-setup-epinio.yml's own domain/ TLS/storage values rather than resetting them); patches Dex's Deployment to mount the mirrored CA (chart has no values-level way to add this volume — confirmed via helm show values); restarts Dex unconditionally; verifies Epinio still answers.
  • manifests/627-epinio-identity-values.yaml.j2 — the dex.connectors/ rolesMapping Helm values, each connector block independently gated.
  • manifests/627-epinio-authentik-blueprint.yaml.j2 — the Authentik-side OAuth2Provider + Application, reusing the existing "Service Groups Mapping" scope mapping 073-authentik-service-protection-blueprint.yaml.j2 already creates, rather than declaring a second, duplicate one.
  • Three new secrets (EPINIO_DEX_GITHUB_CLIENT_SECRET/_AUTHENTIK_CLIENT_SECRET/ _OKTA_CLIENT_SECRET) in the standard secrets-templates pipeline.
  • Two new static tests, both mutation-tested: test-epinio-identity-structure.sh (required-param gating, the union-not-overwrite logic, the unconditional restart, no_log, --reuse-values) and three new assertions in test-jinja-templates-render.sh (per-connector-combination rendering, rootCAs/ insecureSkipEmailVerified land on the right connector only, the bare user role is never dropped).

Deliberately not consolidated into the existing generic protected_services oauth2 mechanism​

073-authentik-service-protection-blueprint.yaml.j2 already has a generic type: oauth2 branch for any service in AUTH10_PROTECTED_SERVICES. It would in principle avoid a second, bespoke blueprint file. Not used here, on purpose: that branch has no default example anywhere in this repository and is unexercised by any currently-configured service — this would be its first real use, and routing Epinio's own already-proven (during the PoC) bespoke mechanism through it would mean trusting two unproven things at once instead of one. Worth revisiting as a future consolidation once that generic path has a real, tested consumer of its own.

Bug found live, fixed in PR #644: reflector collides with Epinio's own bundled copy​

Epinio's own upstream Helm chart already bundles emberstack/reflector as a subchart dependency (confirmed live: release epinio, chart reflector-10.0.58), including a cluster-scoped ClusterRole literally named reflector. The standalone reflector service (028-setup-reflector.yml, same upstream chart, pinned 9.1.9) tried to create a ClusterRole with that same name under a different release, and Helm correctly refused it. This is not a corner case — it is the exact combination this whole plan exists for (anyone installing Epinio, then needing the Authentik connector's cross-namespace trust, hits this every time). Fixed by detecting any already-running reflector controller cluster-wide (its own design has no release-scoped RBAC — any controller watches annotated Secrets cluster-wide regardless of which release deployed it) and skipping the standalone install when one is already present. Found live by imac; not something they attempted to resolve themselves (a design call, correctly left for this repo).

Validation​

GitHub connector, met live except the interactive sign-in itself, 2026-10-27 (urb-agents#2044): imac used a real GitHub org/team, decoded the rendered dex-config Secret directly (clientID/org/teams/redirectURI all correct, rolesMapping pairs user unconditionally with the matched group's admin:<ns> role — gotcha 5's fix genuinely present), confirmed Dex actually restarted and its own logs show the connector loading. Not verified: an actual interactive sign-in through GitHub's consent screen — no browser-automation tool was available in that environment, flagged explicitly rather than claimed. The "no matching group → no roles" case is sound by construction (no catch-all entry in the rendered rolesMapping) but is inference from the rendered config, not an observed failed login.

Authentik connector — re-tested 2026-10-27 (urb-agents#2045), two more bugs found and fixed, one bigger blocker found and NOT fixed here:

  • The reflector/Epinio collision fix itself had a small bug in 028-setup-reflector.yml's own detection task: an unquoted jsonpath value broke ansible.builtin.command's own argument splitting. Fixed. With that fixed, imac confirmed the detection-and-skip design is genuinely correct, not just plausible: it found Epinio's bundled reflector controller and skipped cleanly, and — the real open question from before — decoding the actual mirrored Secret live confirmed Epinio's bundled instance does satisfy this plan's cross-namespace mirroring need in practice.
  • Dex's Deployment had no hostAliases for a .localhost Authentik hostname — the identical trap class as urb-agents#1928's original forgejo.localhost bug, recurring in this new connector. Fixed the same proven way (640-setup-forgejo-runner.yml's own pattern: look up Traefik's ClusterIP, alias the hostname to it, only when that hostname actually ends in .localhost).
  • Past both of those, the connector is still blocked — not by anything in this plan's own scope. Confirmed host-side and in-cluster identically (not an in-cluster-specific issue), so it's purely a Traefik TLS/SNI question. A first fix attempt (tls.domains, based on reading a Traefik log line as a cert-selection mechanism) was retracted after imac re-tested it live with a full Traefik restart and got the identical wrong certificate — the log line turned out to be about a different Traefik concept (TLSOptions resolution) entirely, confirmed by reading Traefik's own source. The real mechanism is still not found; see INVESTIGATE-system-traefik-incluster-sni for the full retraction and what live instrumentation is actually needed next.

Authentik connector — re-tested again 2026-10-28 (urb-agents#2051), the TLS blocker confirmed fixed live, one more real bug found right behind it:

  • The TLSStore workaround (INVESTIGATE-system-traefik-incluster-sni.md) is confirmed working: fresh deploy on 1.6.255, host-side and in-cluster SNI probes both return the real authentik-server-tls certificate instead of Traefik's default — matching serial/fingerprint exactly, not inferred.
  • Going further, with a real client_id/secret this time: 627-setup-epinio-identity.yml itself reports success (Dex restarts with the real connector config), but the Authentik-side blueprint (manifests/627-epinio-authentik-blueprint.yaml.j2) silently never created the provider or application — BlueprintInstance sat at status: error, redirect_uris: This field is required. On this Authentik version (2025.10.3) that field is mandatory; the blueprint never set it. Fixed, reusing the exact shape already proven elsewhere in this repo (073-authentik-2-openwebui-blueprint.yaml.j2) and Dex's own redirect URI (shared across every connector, not a hand-duplicated copy) — covered by two new mutation-tested render assertions.
  • Re-verified live (urb-agents#2054, 1.6.256): the blueprint now applies (BlueprintInstance status: successful; epinio-app and epinio-provider exist with the correct redirect_uris). Both fixes above work together.
  • A third bug, right behind them: pushing into the real sign-in, Dex still could not open the connector — x509: certificate is valid for authentik.localhost - authentik.x - authentik.y. 076-authentik-server-tls-certificate.yaml.j2 built dnsNames with manual {%- dash whitespace control, which with Ansible's trim_blocks merged every list item into ONE garbled SAN string, so no strict TLS client could ever match a hostname. Same bug class as 635-forgejo.yaml.j2 (urb-agents#2026). Fixed with plain block tags, and three new render assertions that check the parsed list (the template had none); a sweep found no other template with the pattern.
  • Verified live, end to end (urb-agents#2056, 1.6.258) — the first complete sign-in for this connector. The certificate's dnsNames is now a real three-entry list; Dex opens the connector with no x509 error; a scripted browser-equivalent flow (Dex /auth as the real epinio-ui client, through Authentik's identification and password stages, back through Dex's callback, code exchange at Dex's token endpoint) produced a real ID token that Dex and Epinio both accept. Epinio's own API then resolved the identity: the global user role, and an admin role scoped to a namespace the identity created. Test namespace deleted afterwards. Note: a token for the epinio-ui client alone is correctly rejected by Epinio (expected audience "epinio-api"); the flow needs the audience:server:client_id:epinio-api scope, Dex's documented cross-client trust.

Okta connector: not attempted — no real Okta tenant available; shares the Authentik-identical insecureEnableGroups/insecureSkipEmailVerified code path already partially exercised by template inspection. Was never expected to hit the Traefik/SNI issue above — Okta is a real external IdP, not reached through this platform's own HostRegexp routing at all.

Verified live, the full workflow (urb-agents#2057, 1.6.258) — signing in, building and deploying as an Authentik user, plus the isolation case:

  • Real epinio login: the CLI performed its own PKCE token exchange and wrote real tokens (audiences epinio-api and epinio-cli). It needs a browser or a person at a terminal, which is inherent to OIDC and not something to fix; imac left the real CLI process running and drove only the browser steps through Authentik's flow executor API.
  • Push, deploy, expose: epinio push built and stored a real app (Paketo Node buildpack, x86), scripts/epinio/epinio-expose-route.sh exposed it, and it answered on both Epinio's own ingress and the Traefik hostname route. The Garage epinio bucket grew after the push, so the data lands where it should.
  • A user in no mapped group: only the default user role, no groups claim at all, a 403 on the mapped namespace and its applications, and still able to create a namespace of their own. This closes the long-open "no matching group lands with no roles" question with an observed result.

Confirmed again on Proxmox (urb-agents#2058, 1.6.260) — the same chain, independently, on the other real deployment target this repo supports. Same result: login → push → expose → Garage worked for the mapped user, and the unmapped user was cleanly walled off. Two real bugs surfaced and fixed as part of closing this out, both in 627-setup-epinio-identity.yml:

  • it assumed Epinio's own Helm repo was still registered from 625-setup-epinio.yml's earlier run in the same container — true only until a uis pull container restart drops Helm's repo list. Now registered unconditionally before the identity helm upgrade (the module is idempotent).
  • its own post-change "Epinio still answers" check hard-failed on every .localhost deploy, even though Epinio was fine — the ansible controller has no route to cluster ClusterIPs at all for that domain, so the check could never pass from there. Matched to 625-setup-epinio.yml's own equivalent check: advisory (ignore_errors), not a gate.

One operational note for whoever next automates a sign-in through Authentik's flow executor API for testing (both ops and imac have now separately driven this headless, each hitting a different part of it): the consent step's POST needs a Referer header, or Django's CSRF check rejects it with "Referer checking failed - no Referer" even with a valid X-Authentik-CSRF header and cookie. Invisible from a real browser, which always sends one.

How the role mapping actually behaves — read this before configuring it​

Settled from Epinio's own source (internal/auth/role.go, v1.14.3), not inferred. admin:workspace is literal role=admin, namespace=workspace syntax, split on :. It grants admin on a namespace named exactly workspace, nothing else. It is not "admin of whatever namespace this group creates", and this static form cannot express that.

  • The default user role (everyone, mapped or not) has namespace_write, so anyone can create a namespace, but not app_write. Creating your own namespace therefore does not let you deploy into it. imac's first push, into a namespace they had created, got 403 user unauthorized for exactly this reason.
  • So with a mapping like HQ -> admin:workspace, HQ members can deploy only into the shared workspace namespace. This also settles an earlier doubt: the admin role imac saw on a namespace they created was Epinio granting it to the creator, not the group mapping, which only ever applies to the namespace it names.
  • To give each team its own namespace, create those namespaces ahead of time and map each team's group to admin:<its-namespace>. There is no way yet to say "admin of any namespace I create".

Not proven, and not blocking:

  • The token's groups claim carried a duplicate entry (["HQ","HQ"]). imac cleared Authentik: the user has exactly one membership and the mapping expression cannot duplicate. It is consistent with Dex merging the ID token's claim with a second copy from userinfo, but that mechanism was not confirmed in Dex's source. Cosmetic as far as anyone can tell.
  • Okta, which needs a real tenant. Out of scope for now.
  • Building on arm64 (ops' gate 16) is untested here; the verified build ran on x86.