feat: backfill static, pass-through and EMA auth clients

Merged
DA
1mo ago
+7307-337

AIM-588

Stacked on #7768 (← #7761 ← #7653).

Summary

Extends the per-org typed auth-client backfill from #7768 with header and EMA phases, behind the same admin migration button and the same separate "Auth clients" status.

  • Header phase.
    • A source's credential headers become a static_credential client (stored values, ciphertext copied without decrypting) or a pass_through client (forwarded headers), linked to every server on that source. Credential headers are Authorization, secret static headers and forwarded headers.
    • Credential headers are copied onto an upstream OAuth client's auth client only when one source owns all of that client's servers. Otherwise it's reported oauth_client_shared_across_sources and existing copies are retired. Hosted and unproxied servers count as their own source.
    • Copies stay in sync with the source. Rotation, mapping changes and case-only renames update the copy in place. A stored↔forwarded switch retires the old client and creates the new type.
  • EMA phase.
    • Ready bindings are grouped per (issuer, client, resource) into one ema client, which stores the exact resource and keeps scopes in sync.
    • Servers are matched the way the runtime does: a valid persisted protected-resource record first (honouring its resource and authorization_servers), then URL equality, with tunneled servers under their derived issuer.
    • Mismatches are reported as issuer_not_allowed or resource_not_matched. Same-origin servers that can't be confirmed are reported as a server_not_matched warning, which doesn't block completion.
  • Reconciliation. Backfilled header and EMA rows whose source is gone are retired. A raced write keeps the client and its links.
  • requires_upstream_auth is set NULL→true for servers linked through OAuth, header or EMA clients. It never overwrites false.
  • Concurrency. Each phase runs in its own transaction under a per-org pg_try_advisory_xact_lock. A second run returns "already in progress", and the status shows "run in progress". The admin apply runs under context.WithoutCancel with a 15-minute timeout. A failed phase rolls back its writes and its counts, and is named in the run response.
  • Admin UI. Per-kind counts, reasons and ids for unresolved items, a separate warnings list, and the in-progress state.

Motivation

Milestone 2 of the multiple-upstream-credentials RFC needs a stable typed auth client for every existing upstream identity before permissions and the resolver can use them. #7768 covered OAuth clients; this covers stored and forwarded credentials and EMA, so every existing outbound configuration has a typed client before cutover.

Notes

  • No runtime change. Nothing reads these tables yet, and the existing outbound configuration stays authoritative.
  • No-auth is not modeled as a client. It stays the existing no_auth selection, plus requires_upstream_auth for the server-level declaration.
  • Non-credential headers stay server headers. The resolver (AIM-594) applies server headers, then client headers.
  • Platform MCP parity: not needed. No Platform MCP tool reads or writes upstream client configuration this changes.
  • Admin MCP parity: not needed. This is a one-time staff rollout operation on the existing admin page, the same reasoning as #7659.

🤖 Generated with Claude Code


Summary by cubic

Extends the typed auth-client backfill to record static credential, pass-through, and EMA clients for every configured upstream identity, so all existing upstream configurations have typed clients before cutover. No runtime code reads these tables yet.

  • Credential headers become static_credential or pass_through clients linked to every server on their source, and are copied onto upstream OAuth clients.
  • Ready identity chaining bindings are grouped per (issuer, client, resource) into one ema client.
  • Forwarded headers the proxy refuses are reported unresolved instead of backfilled.
  • Each phase runs detached from the request in its own transaction; a per-org lock makes a second run report "already in progress".
  • Copies and EMA scopes stay in sync across runs, and stale header copies retire with their OAuth auth client.

🚀 Preview Environment (PR #7810)

Preview URL: https://pr-7810.dev.getgram.ai

ComponentStatusDetailsUpdated (UTC)
✅ DatabaseReadyExisting database reused2026-10-21 13:11:20.
✅ ImagesAvailableContainer images ready2026-10-21 13:12:53.

Gram Preview Bot