Skip to content

feat(auth): support env vars for OAuth provider credentials - #3048

Merged
tlgimenes merged 3 commits into
mainfrom
tlgimenes/fix-auth-client-secret
Apr 8, 2026
Merged

tlgimenes merged 3 commits into
mainfrom
tlgimenes/fix-auth-client-secret

Conversation

@tlgimenes

@tlgimenes tlgimenes commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

After removing the build-auth-config init container (#3047), OAuth sign-in broke because the Helm lookup function doesn't reliably inject secrets into the ConfigMap (e.g. during ArgoCD rendering). This PR adds env var support for auth provider credentials so they can be injected directly via Kubernetes Secrets as environment variables, removing the need for the init container entirely.

Auth config is now parsed through a Zod schema with file-first, env-fallback semantics: values from auth-config.json take precedence, missing/empty values fall back to env vars (AUTH_GOOGLE_CLIENT_ID, AUTH_GOOGLE_CLIENT_SECRET, AUTH_GITHUB_CLIENT_ID, AUTH_GITHUB_CLIENT_SECRET, AUTH_RESEND_API_KEY).

How to Test

  1. Deploy with AUTH_GOOGLE_CLIENT_ID and AUTH_GOOGLE_CLIENT_SECRET set as env vars (via k8s Secret) and no Google credentials in auth-config.json
  2. Attempt Google OAuth sign-in
  3. Expected: sign-in works without CLIENT_ID_AND_SECRET_REQUIRED error

Migration Notes

New optional env vars for auth secrets — no action needed if credentials are already in auth-config.json. For Helm users, credentials can now be set under secret.AUTH_GOOGLE_CLIENT_ID, etc. in values.yaml. Helm chart bumped to 0.3.1.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Switch auth to AUTH_* environment variables parsed by a single zod schema, removing auth-config.json and the Helm ConfigMap mount. Restores OAuth/email flows without the init container and simplifies Docker/Helm; the CLI config view now shows env var names in original case.

  • New Features

    • New auth-env.ts parses AUTH_* into runtime config (Google/GitHub OAuth, Resend/SendGrid, Microsoft SSO, magic link, email OTP, and email/password toggle); JWT now requires MESH_JWT_SECRET or BETTER_AUTH_SECRET only.
    • Forward all AUTH_* in build-child-env.ts; CLI config view shows env var names (original case) and provider status.
    • Helm/Docker Compose: drop auth-config.json mounts and ConfigMap; add Secret entries for AUTH_*; chart bumped to 0.3.1.
  • Migration

    • If you used auth-config.json, move values to env vars (e.g. AUTH_GOOGLE_CLIENT_ID, AUTH_GITHUB_CLIENT_SECRET, AUTH_RESEND_API_KEY, AUTH_SENDGRID_API_KEY, AUTH_SSO_MS_CLIENT_ID). The auth key in config.json is ignored; config.json remains for non-auth settings.
    • Helm users: set .Values.secret.AUTH_*; no ConfigMap/auth-config mount needed.

Written for commit 5765587. Summary will update on new commits.

Auth config secrets (Google/GitHub client ID/secret, Resend API key) can
now be injected via environment variables instead of requiring the
build-auth-config init container. A Zod schema parses the auth-config
file with file-first, env-fallback semantics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions

github-actions Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Release Options

Suggested: Minor (2.248.0) — based on feat: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.247.1-alpha.1
🎉 Patch 2.247.1
❤️ Minor 2.248.0
🚀 Major 3.0.0

Current version: 2.247.0

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

tlgimenes and others added 2 commits April 7, 2026 22:10
Auth configuration is now driven entirely by AUTH_* environment
variables parsed through a single Zod schema (auth-env.ts). This
removes the need for auth-config.json, the configmap-auth Helm
template, and the init container that merged secrets into the file.

config.json is still supported for non-auth config (theme, logo,
monitoring).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
All config-view sections now display the actual environment variable
names (NODE_ENV, DATABASE_URL, AUTH_GOOGLE_CLIENT_ID, etc.) instead of
camelCase property names. Padding bumped to 36 chars for longer names.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@tlgimenes
tlgimenes merged commit da4c9e1 into main Apr 8, 2026
15 checks passed
@tlgimenes
tlgimenes deleted the tlgimenes/fix-auth-client-secret branch April 8, 2026 01:19
viktormarinho added a commit that referenced this pull request Aug 3, 2026
…othing

The chart has had no template consuming .Values.configMap.authConfig or
secret.authConfigSecretName since configmap-auth.yaml was deleted (#3048,
env-var auth) — but the README and examples/secrets-example.yaml kept
documenting both, including a second Secret with camelCase keys
(googleClientId, resendApiKey) the server never reads. This is an active
trap: the real prod values in deco-apps-cd carry a full authConfig block
(google, resend, magic-link) that renders to nothing — auth there actually
works because the ExternalSecret feeds AUTH_* keys via envFrom.

README now shows the real mechanism (AUTH_* in meshConfig/Secret, schema in
apps/api/src/auth/auth-env.ts) and the example Secret carries AUTH_* keys.
viktormarinho added a commit that referenced this pull request Aug 3, 2026
001.md described the file-based auth-config.json design that #3048/#5120
replaced with AUTH_* env vars, plus a pre-split architecture; nothing links to
it except its README entry and one step of the add-mcp-tools skill, both
removed (the skill's 'Document in Spec' step told contributors to document new
tools in a file that described a system that no longer exists).
monitoring-share-plugin.md was referenced by nothing at all.
viktormarinho added a commit that referenced this pull request Aug 3, 2026
…5579)

* chore: delete the dead auth-config.json tail and the stray EFS RFC

Auth moved to AUTH_* environment variables (auth-env.ts) — core/config.ts even
warns that a config-file 'auth' key is ignored. Nothing reads auth-config.json
anymore, but its tail survived everywhere:

- auth-config.json at the repo root: snuck in via #5575 (a sandbox-daemon PR),
  tracked ever since, read by nothing. Deleted.
- apps/api/auth-config.example.json, tests/resilience/auth-config.test.json:
  referenced by nothing. Deleted.
- .github/workflows/e2e.yml wrote the file before every run — for nothing.
  Step deleted.
- .cursor/worktrees.json copied a file that does not exist. Line deleted.
- apps/api/src/auth/index.ts's header claimed the exact opposite of reality
  ('file-based, not environment variables'). Fixed, with the .gitignore entry,
  the AGENTS.md config line, and config.example.json's pointer.
- deploy/helm/studio/README.md documented a configmap-auth.yaml template that
  does not exist in templates/. Section removed, following ones renumbered.

efs-spec.md (an L2 golden-cache RFC draft) also landed at the root in #5575.
Deleted — it was never referenced by anything in the repo.

Not touched: decostudio-alias/ stays at the root on purpose — it is the
published npm alias (decostudio → decocms) with its own publish workflow, and
it must stay OUT of the workspaces globs so its 'decocms': '*' dependency
resolves against the registry instead of being workspace-linked. spec/001.md's
auth-config mentions are a historical design document and were left alone.

* docs(helm): stop documenting authConfig values the chart renders to nothing

The chart has had no template consuming .Values.configMap.authConfig or
secret.authConfigSecretName since configmap-auth.yaml was deleted (#3048,
env-var auth) — but the README and examples/secrets-example.yaml kept
documenting both, including a second Secret with camelCase keys
(googleClientId, resendApiKey) the server never reads. This is an active
trap: the real prod values in deco-apps-cd carry a full authConfig block
(google, resend, magic-link) that renders to nothing — auth there actually
works because the ExternalSecret feeds AUTH_* keys via envFrom.

README now shows the real mechanism (AUTH_* in meshConfig/Secret, schema in
apps/api/src/auth/auth-env.ts) and the example Secret carries AUTH_* keys.

* chore(api): delete apps/api/spec — a stale v1 design document

001.md described the file-based auth-config.json design that #3048/#5120
replaced with AUTH_* env vars, plus a pre-split architecture; nothing links to
it except its README entry and one step of the add-mcp-tools skill, both
removed (the skill's 'Document in Spec' step told contributors to document new
tools in a file that described a system that no longer exists).
monitoring-share-plugin.md was referenced by nothing at all.

* chore: delete .cursorindexingignore

Stale editor config from 2024 (last touched in #1218); the paths it excluded
no longer exist in the repo.
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.

1 participant