ADR 0003: Composable HTTP authentication and key pass-through
Why HTTP serve acts as a stateless OAuth 2.1 Resource Server alongside static bearer tokens and same-origin caller key pass-through.
Context
what-if runs primarily over local stdio and trusted tailnet proxies, where a static server_token suffices. However, hosted and GUI MCP clients require OAuth 2.1 discovery and bearer token verification, and multi-caller gateways often need per-caller upstream API keys without embedding an identity provider or token database inside a minimal static Go binary.
Decision
- External IdP as a stateless Resource Server:
what-if servedelegates user login and client registration to an external Authorization Server, serving RFC 9728 Protected Resource Metadata (/.well-known/oauth-protected-resourceand/.well-known/oauth-protected-resource/_/mcp) and verifying bearer tokens via asymmetric JWKS (RS*,PS*,ES*,EdDSA) and/or RFC 7662 introspection using Go stdlib crypto andgo-sdk/auth.alg:none, symmetricHS*, and fallback from invalid JWT signatures to introspection are strictly rejected. - Preserve static bearer compatibility:
server_tokenremains verified in constant time alongside OAuth when both are configured so headless CI and cron scripts keep working without OAuth client credentials. - Header-scoped caller pass-through: Because
go-sdk's Streamable HTTP transport dispatches tool handlers on session goroutines, pass-through reads caller keys fromreq.Extra.Header(X-Upstream-API-Keywhen combined with static or OAuth inbound auth;Authorization: Bearerwhen standalone) rather than HTTP middleware context. Passed-through keys overridetarget.APIKeyonly whentarget.BaseURLmatches the defaultbase_url, bind Streamable HTTP sessions via a SHA-256UserID, and are scrubbed from errors before reaching MCP callers.
Consequences
go.modadds zero new external dependencies and< 11 MBscratch container images stay untouched.- Multi-tenant and remote OAuth MCP clients work without an embedded login UI or database.
- Backends configured on distinct
tiers.<name>.base_urlhosts never receive caller pass-through credentials from another origin.
Connections
Local graphLinked from
- “ADR 0003: Composable HTTP authentication and key pass-through”