---
type: Log
title: "Add composable OAuth 2.1 Resource Server and caller key pass-through"
description: "Added zero-dependency JWKS and RFC 7662 OAuth 2.1 Resource Server verification, static bearer composition, and header-based caller API-key pass-through for HTTP MCP serving."
status: stable
tags: [log, auth, oauth, security, mcp]
---

# Add composable OAuth 2.1 Resource Server and caller key pass-through

Added composable inbound authentication and outbound caller upstream key pass-through to `what-if serve` without adding new external module dependencies.

## Summary of changes

- Added `[auth]` configuration, `WHAT_IF_SERVER_TOKEN_FILE`, and `WHAT_IF_AUTH_*` environment overrides in `internal/config`, including strict URL/duration validation, `Redacted()` reporting, and `SanitizeErrorWith` per-request secret scrubbing.
- Implemented `internal/auth` covering RFC 8414 / OIDC issuer discovery, JWKS caching with `30s` rotation cooldown and asymmetric JWS verification (`RS*`, `PS*`, `ES*`, `EdDSA`), RFC 7662 introspection (`client_secret_basic` / `client_secret_post`) with a bounded SHA-256-keyed cache, and RFC 9728 Protected Resource Metadata helpers.
- Wired `req.Extra.Header` pass-through extraction in `internal/mcpserver/server.go`, same-origin target key isolation in `internal/decide/service.go`, metadata and bearer middleware in `internal/mcpserver/http.go`, and auth reporting in `internal/cli/doctor.go`.
- Updated `docs/reference/configuration.md`, `docs/architecture/system.md`, `docs/usage/quickstart.md`, and added `docs/adr/0003-http-auth-and-passthrough.md`.
