Skip to content

[codex] Use admin role for platform admin access#1453

Merged
jonastemplestein merged 1 commit into
mainfrom
relieved-snow
Jun 10, 2026
Merged

[codex] Use admin role for platform admin access#1453
jonastemplestein merged 1 commit into
mainfrom
relieved-snow

Conversation

@jonastemplestein

@jonastemplestein jonastemplestein commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the custom superadmin OAuth scope model with the Better Auth admin-plugin role as the platform-admin source of truth. Auth access tokens now carry the existing role / is_admin claims, and OS derives global itx access from those claims or from the admin API secret.

Also renames the auth admin oRPC/router/UI namespace from superadmin to admin, updates the CLI admin impersonation strategy, renames the bootstrap admin seed path/account, and refreshes docs around the access model.

Impact

  • Browser/OAuth users with Better Auth user.role === "admin" are clearly identifiable as admin in OS principals.
  • HTTP clients using the OS admin API secret remain clearly identifiable via Principal.type === "admin" / authType: "admin_api_secret".
  • The custom superadmin OAuth scope is removed from shared auth claims and auth-provider advertised scopes.
  • The admin allowlist env binding is now ADMIN_ALLOWLIST; no legacy SUPERADMIN_* compatibility path is retained.

Validation

  • pnpm exec oxlint . --threads 1 --deny-warnings
  • pnpm --dir apps/auth typecheck
  • pnpm --dir apps/os typecheck
  • pnpm --dir apps/auth-contract typecheck
  • pnpm --dir packages/iterate typecheck
  • pnpm --dir apps/os exec vitest run src/auth/principal.test.ts src/domains/inbound-mcp-server/mcp-handler.test.ts
  • pnpm --dir apps/os test
  • pnpm exec oxfmt --check apps/auth-contract/src/index.ts apps/auth/src apps/auth/scripts apps/auth/alchemy.run.ts apps/os/src apps/os/docs packages/iterate/src/cli.ts packages/iterate/README.md packages/shared/src/auth-claims.ts apps/auth-example/.env.example docs/plan-replace-clerk-with-auth-worker.md

Note

High Risk
Changes how platform-wide authorization is derived (tokens, MCP, itx global access) and renames admin API routes/env; misconfiguration could block operators or widen access until tokens refresh.

Overview
Replaces the custom superadmin OAuth scope with Better Auth’s platform admin role (user.role === "admin") as the source of truth for deployment-wide access. Auth no longer advertises or server-grants that scope; access tokens carry is_admin / role claims instead, and project scoping stays on project:<id> entries.

Auth renames the operator surface from superadmin to admin: oRPC contract paths (/admin/oauth/*), TanStack routes (/admin/clients), env (ADMIN_ALLOWLIST, admin seed SQL), bootstrap user (admin@nustom.com), and helpers (isPlatformAdminUser, platformAdminOnlyMiddleware). Deploy-time allowlist backfill now uses a platformAdminBackfill marker table (replacing superadminBackfill naming in seed generation).

OS threads admin through principals: UserPrincipal.isAdmin, principalIsAdmin, and accessForPrincipal treat admin API secret or admin-role users as "all" project access. Inbound MCP skips the project-scope gate when principal.isAdmin instead of checking a superadmin scope. Consent UI and shared ITERATE_SUPERADMIN_SCOPE / hasSuperadminScope are removed.

CLI/docs rename the CI impersonation strategy from superadmin to admin and update smoke/bootstrap references to the new bootstrap admin email.

Reviewed by Cursor Bugbot for commit 2785777. Bugbot is set up for automated code reviews on this repo. Configure here.

Environment Config Lease

No active environment config lease.

OS

Status: released
Commit: 2785777
Preview: https://os.iterate-preview-1.com
Summary: Preview app released.
Workflow run
Updated: 2026-06-10T14:47:57.444Z

Semaphore

Status: released
Commit: 2785777
Preview: https://semaphore.iterate-preview-1.com
Summary: Preview app released.
Workflow run
Updated: 2026-06-10T14:47:44.656Z

@jonastemplestein jonastemplestein marked this pull request as ready for review June 10, 2026 14:00
Comment thread apps/os/src/auth/principal.ts Outdated
@jonastemplestein jonastemplestein changed the title [codex] Fix superadmin itx access [codex] Use admin role for platform admin access Jun 10, 2026
Comment thread apps/os/src/domains/inbound-mcp-server/mcp-handler.ts
@jonastemplestein jonastemplestein force-pushed the relieved-snow branch 2 times, most recently from bfe7461 to 4b0a89a Compare June 10, 2026 14:11
Comment thread apps/auth/src/server/oauth-project-selection.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2785777. Configure here.

Comment thread apps/auth/scripts/render-admin-seed.ts
Comment thread apps/os/src/auth/principal.ts
@jonastemplestein jonastemplestein merged commit 40d0f90 into main Jun 10, 2026
13 checks passed
@jonastemplestein jonastemplestein deleted the relieved-snow branch June 10, 2026 14:45
mmkal added a commit that referenced this pull request Jun 10, 2026
Conflict resolutions:
- packages/iterate/src/cli.ts: took this branch's version wholesale.
  Main's only change was the superadmin->admin rename (#1453), and every
  renamed region (auth strategies, impersonation dance, device flow,
  --superadmin login flag) was already deleted here in the OAuth PKCE
  rewrite — there is nothing to port.
- apps/os/e2e/vitest/e2e-test-map.e2e.test.ts: accepted main's deletion
  (codemode rip #1447); this branch had only touched a doc comment.
- event-stream-terminal.tsx (auto-merged, needed follow-up): main's new
  listChildren itx walk gets the authedFetch arg, matching the getState
  adaptation from the previous merge.
- apps/iterate-com skills-registry.ts: took main's regenerated copy;
  this branch carried a stale-formatted version of the generated file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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