Skip to content

feat(auth): add upstream OIDC preflight check and staging validation overlay - #3

Open
binyangzhu000-sudo wants to merge 7 commits into
fix/codex-oauth-callback-timeout-20260817from
feat/upstream-oidc-rollout-prep-20260818
Open

feat(auth): add upstream OIDC preflight check and staging validation overlay#3
binyangzhu000-sudo wants to merge 7 commits into
fix/codex-oauth-callback-timeout-20260817from
feat/upstream-oidc-rollout-prep-20260818

Conversation

@binyangzhu000-sudo

Copy link
Copy Markdown
Contributor

背景

生产要求 AUTH_IDENTITY_MODE=upstream-oidc,但仓库里原先没有任何东西能让人在申请 DNS / 密钥 / 部署窗口之前先确认一个候选 issuer 合不合格;而且唯一能跑这个模式的路径是直接上生产。

改了什么

  • scripts/check-upstream-oidc.mjs:把 src/auth/upstream-oidc.tssrc/auth/config.ts 在 discovery 阶段强制的规则逐条复刻成自检脚本。不需要 build、不需要 client secret、不需要集群,身份方自己就能跑。它还会直接打印 discovery 文档隐含的 AUTH_UPSTREAM_ENDPOINT_HOSTS 值——端点常常不在 issuer 主机上(Google 就是三个不同主机),手填极易漏。
  • deploy/kubernetes/staging-upstream-oidc.example/:把生产的身份与凭据画像套到 staging 主机上(upstream-oidc + redis-subject-map + 加密密钥环,删掉 OIDC_USERS_JSONMCP_ATLAS_SUBJECT_KEYS_JSON),但保留 PLUGIN_RELEASE_TIER=staging,因此带 staging 字样的 issuer 在这里可用、在生产闸门仍被拒。
  • docs/UPSTREAM_OIDC_REQUIREMENTS.md:记录 provider 必须满足的全部规则,含 discovery 层面验不出来的那条——id_token 的 email_verified 必须是布尔 true

验证

  • tsc 干净,npm test 76/76 通过
  • 自检脚本对真实 issuer 实测:Google(accounts.google.com)19 项全过;四个 Atlas 候选域名全部 FAIL(三个不解析、www 的 discovery 404)。
  • 两个 overlay 都用 kubectl kustomize 验证渲染正确,生产 overlay 无回归。
  • 另外用一套 44 个变量的假值灌进 validate:production-config,输出 PRODUCTION_CONFIG_VALID —— 说明生产 overlay 的变量集合完整自洽、不缺项。

两点说明

  1. base 指向 fix/codex-oauth-callback-timeout-20260817 而不是 main,目的是把 review 范围收在本次新增的 6 个文件内。父分支自己的合并目标是一个独立待定问题:本仓库是公开仓库,而公开的 main 只有 32 个文件(纯 npm 版 MCP server),src/auth/deploy/kubernetes/、reviewer 身份与取密码流程都只存在于未合并分支上——把它们合进 main 等于公开内网 K8s 清单、镜像仓库路径与 dev 域名。合并范围建议由仓库负责人决定。
  2. 该 overlay 会停掉 staging 的 reviewer 密码登录,而 scripts/codex-oauth-e2e.mjsnpm run test:codex-oauth:chrome-live 都从 stdin 读 reviewer 密码、无法驱动上游登录,所以启用期间浏览器流程需人工验证。这一点已写进 deploy/kubernetes/README.md

关联

上游 provider 已在 AtlasCloudTeam/kubedl 侧实现(PR AtlasCloudTeam/kubedl#601),已用本仓库的真实校验代码跨仓库验证通过。

github-actions Bot and others added 5 commits August 14, 2026 04:18
…overlay

Public production requires AUTH_IDENTITY_MODE=upstream-oidc, but nothing in the
repository let an operator confirm a candidate issuer before requesting DNS,
secrets, and a deployment window, and the only way to exercise the mode was to
promote straight to production.

- scripts/check-upstream-oidc.mjs mirrors the discovery-time rules enforced by
  src/auth/upstream-oidc.ts and src/auth/config.ts, needs no build step or
  client secret, and prints the AUTH_UPSTREAM_ENDPOINT_HOSTS value implied by
  the discovery document. Endpoints commonly live on hosts other than the
  issuer, so that value is easy to get wrong by hand.
- deploy/kubernetes/staging-upstream-oidc.example applies the production
  identity and credential profile to the staging hosts while keeping
  PLUGIN_RELEASE_TIER=staging.
- docs/UPSTREAM_OIDC_REQUIREMENTS.md records every provider requirement,
  including the id_token email_verified boolean that discovery cannot prove.
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