fix(iam): make the ZITADEL OIDC secrets and identity links IaC-owned

Every consumer SSO login failed for two independent reasons, and neither was
recorded in git.

1. The OIDC client secrets lived only in the cluster. They are written by
   scripts/iam/zitadel-provision.py, whose `apply` phase calls
   _generate_client_secret for every app on every run. A rotation therefore
   invalidated the stored secret in ArgoCD, Grafana, MinIO, Immich and
   Paperless, with no git value to compare against. Declaring the five Secrets
   as SOPS manifests makes ArgoCD the owner, so the next rotation is a
   reviewable diff instead of silent drift.

2. Forgejo, Paperless and Immich store the identity-provider link inside their
   own databases, not in Kubernetes. Those rows still carried the Authentik
   subject and provider, which produced three different symptoms from one
   cause: Forgejo never left /user/link_account, Paperless showed the social
   signup page, and Immich answered 400 "email already linked to different
   account". The PostSync Job re-points each row at the ZITADEL `sub`,
   matching on email or username rather than the numeric ids this was first
   observed on, so a re-run converges.

Verified with a real browser login against a live ZITADEL session: Forgejo,
Paperless, Immich, Grafana and ArgoCD all reach their authenticated landing
page. Vault has no UI by design. MinIO remains open: the operator sidecar
serves its console with no OIDC environment, so it advertises form login only.
This commit is contained in:
2026-10-31 13:37:04 -07:00
parent 41dcda819e
commit cf1263235b
8 changed files with 272 additions and 0 deletions
+5
View File
@@ -6,6 +6,11 @@ resources:
# RoleBinding). Authentik is retired, so the file is gone; keep this list in
# step with the directory or kustomize fails the whole app.
- smtp-gotify.yaml
# Repairs the ZITADEL subject stored inside the Forgejo, Paperless and Immich
# databases. Those links are not Kubernetes objects, so without this Job a
# fresh cluster (or a provider change) leaves every one of them pointing at
# the old subject and SSO cannot complete.
- identity-link-repair-job.yaml
# IAM provisioning is manual-only (security-sensitive).
# Script: scripts/iam/zitadel-provision.py