ADR 0009: oauth-proxy as an authorization server — opaque tokens, memory-only state, no transparent refresh
Context
oauth mode (ADR 0008) requires every MCP client to be hand-registered in
Redmine’s admin panel with its exact redirect URI, since Doorkeeper has no
Dynamic Client Registration (DCR). REDMINE_AUTH_MODE=oauth-proxy closes
that gap: this server becomes an authorization server in its own right,
accepting RFC 7591 DCR and running its own authorization-code + PKCE flow
against /authorize//token, which in turn drives a second,
server-internal authorization-code + PKCE flow against Redmine using one
operator-registered upstream OAuth application. This ADR records the three
decisions with the most durable consequences: what a client-facing token
is, where the resulting state lives, and why a token that expires stays
expired until the client asks for a new one.
Decisions
- Opaque, digest-keyed tokens — never a signed JWT. A
rup_at_/rup_rt_token is 256 bits ofOsRngoutput, stored server-side keyed by its SHA-256 digest; the plaintext is never a map key and never appears in aDebug/core-dump-walkable structure. The reference implementation (FastMCP’sOAuthProxy) signs a JWT and then immediately uses it as a database lookup key once verified — the signature is checked and then never consulted again. Skipping it costs nothing this design needs (there is no offline verifier anywhere else that would want to check the signature independently) and avoids a signing key, a rotation story, and an algorithm-confusion surface.REDMINE_MCP_JWT_SIGNING_KEY/_FILEis accepted and ignored, with one startupWARNnaming it as unused, so the reference server’s.envstill boots here. - All proxy state is in-memory, bounded, and swept lazily on write — no
persistence, no shared/multi-replica state. The client registry, every
in-flight authorization transaction, every authorization code, and every
proxy access/refresh token live in
Mutex-guarded maps inside this process. There is noFASTMCP_HOME-equivalent directory, no encryption key, no directory-permissions surface to get wrong. The cost is bounded and self-healing: a restart drops every registration and session, and an MCP client re-registers and re-authorizes driven by the same401challenge it already implements for the ordinary token-expiry case. Multiple replicas behind a round-robin load balancer are unsupported — a flow that starts/authorizeon one instance and lands/auth/callbackon another fails — so this mode is documented as single-instance (or sticky-session) only, indocs/oauth-setup.md. - No transparent refresh inside the request path — refreshing happens
exactly once, in
/token’srefresh_tokengrant. FastMCP’s proxy refreshes upstream transparently inside its bearer-verification path, because its JWT proxy tokens are signed with a lifetime independent of the upstream token and can outlive it. This design’s proxy access token is deliberately capped at the upstream token’s own remaining lifetime (it has no independent lifetime to claim), so there is nothing for a transparent refresh to buy: it would add a per-token async lock, a thundering-herd risk at every synchronized expiry, and latency on a request path that must stay fast, purely to solve a problem therefresh_tokengrant already solves within the protocol. A proxy access token whose upstream token has expired isinvalid_token; the client uses its refresh token, exactly as OAuth 2.1 intends.
Consequences
- A client that never implements the refresh grant re-authorizes in a
browser at every upstream expiry, and a deployment whose upstream OAuth
application has
use_refresh_tokendisabled never gets a refresh token to use in the first place (logged once per process, not once per request). Both are documented indocs/oauth-setup.mdrather than worked around, since a silent workaround (e.g. accepting a non-standard longer-lived token) would be a security regression, not a fix. - Refresh tokens rotate, and reuse of an already-rotated one kills the whole session and revokes it upstream immediately — the standard cost of rotation with reuse detection. A client that legitimately retries a dropped refresh response will occasionally trip this and have to re-authorize; the alternative is accepting replay of a stolen refresh token, which is worse.
- A restart, or a second replica, loses in-flight and issued state.
Accepted per the memory-only decision above; the store types are behind a
narrow interface (
mint/resolve/take/redeem/retire), so a future durable backend is a swap behind that interface rather than a rewrite. get_mcp_server_infoexposesregistered_clients/active_sessionscounts in this mode,nullelsewhere — enough for an operator to tell whether a restart dropped state, without exposing a client id, name, or subject that would let one caller learn who else is connected.- Upstream sessions are capped and expire, like every other proxy store.
A session with no refresh token is bounded by its upstream access token’s
own expiry; a refresh-bearing one is bounded by the same 30-day
REFRESH_TTLthe proxy’s own refresh token already uses, since Doorkeeper refresh tokens never expire on their own. Swept lazily on the next successful authorization (this mode’s only session-creating path), with the swept session’s refresh token — never its already-expired access token — revoked upstream in a best-effort background task, only when the session carried one. - The client registry never evicts a live or recently-used registration
to make room for a new one.
POST /registeris intentionally unauthenticated (RFC 7591 DCR), so a full registry sweeps every registration that is neither in the live set (an unexpired proxy access or refresh token, derived fromTokenStore/RefreshStorethe same way the upstream session deadline above is) nor used within the last hour (CLIENT_IDLE_TTL, well aboveTRANSACTION_TTLso a registration mid-authorization is never at risk); a still-full registry after the sweep degrades to the existing503+Retry-After. This trades a bounded/registerlockout under sustained attacker traffic (existing clients keep working; new ones wait out the idle TTL) for the alternative of evicting a client that is mid-flow or holds a live session, which is strictly worse.