Skip to content

Document gateway JWT for upstream MCP server authentication#623

Open
dshoen619 wants to merge 7 commits into
masterfrom
agent-sec-jwt-upstream-server
Open

Document gateway JWT for upstream MCP server authentication#623
dshoen619 wants to merge 7 commits into
masterfrom
agent-sec-jwt-upstream-server

Conversation

@dshoen619
Copy link
Copy Markdown
Contributor

Summary

Documents the gateway JWT feature added in agent-security#162 and the Redis-backed shared-key follow-up in agent-security#172.

Adds a new Upstream Authentication (Gateway JWT) section to the MCP Gateway architecture page so users understand how the gateway proves request origin to upstream MCP servers, and gives them everything they need to verify on their side.

What's documented

  • Purpose — how the signed X-Gateway-Auth header lets upstream MCP servers reject traffic that didn't flow through the gateway (preventing bypass of authN/authZ/consent)
  • How it works — a sequence diagram showing Ed25519 signing, lazy JWT refresh (re-sign within 30s of expiry), and the optional upstream JWKS verification path
  • JWT claims tableiss, sub, aud, exp, iat, nbf, jti, tenant
  • Two headers coexist — short table clarifying the roles of Authorization: Bearer (upstream OAuth) vs X-Gateway-Auth: Bearer (gateway identity proof)
  • Verification snippet — ~10-line jose example for upstream servers, using createRemoteJWKSet so JWKS caching and key rotation are handled automatically
  • Key rotation note — signing key is cached in Redis (encrypted at rest) and shared across all gateway replicas, so JWTs survive restarts and the JWKS endpoint is consistent across pods; keys rotate on roughly a 90-day cadence
  • ConfigurationGATEWAY_JWT_TTL_SECONDS env var (default 300) and pointer to the platform Settings > Upstream Authentication (JWT) panel

Also updated:

  • System Architecture Overview diagram — Gateway → Upstream edge now labeled Proxy MCP + X-Gateway-Auth JWT, plus a dashed optional verification arrow back to the gateway's JWKS endpoint
  • Data Flow table — Gateway → Upstream MCP row mentions the signed X-Gateway-Auth JWT with an anchor link to the new section

Scope decisions

  • Kept to the architecture page only (not platform or host-setup), since the feature is always-on with no required customer configuration on the gateway — upstream-side verification is the only user-visible surface
  • Intentionally omitted Redis SET NX coordination, AES-256-GCM / KMS internals, and replica-count details — implementation specifics with no troubleshooting value for end users

Test plan

  • Verify the new section renders correctly (mermaid sequence diagram, tables, code block)
  • Confirm the updated System Architecture Overview diagram renders with the new edges
  • Check that the anchor link from the Data Flow table (#upstream-authentication-gateway-jwt) resolves correctly

🤖 Generated with Claude Code

dshoen619 and others added 2 commits April 19, 2026 15:12
Add a new "Upstream Authentication (Gateway JWT)" section to the MCP
Gateway architecture page covering the X-Gateway-Auth header, JWKS
endpoint, JWT claims, verification snippet, and key rotation. Update the
System Architecture Overview and Data Flow table to show the signed JWT
attached to upstream requests and the optional JWKS verification path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Correct the earlier "ephemeral per-pod" framing now that the signing key
is cached in Redis (encrypted at rest) and shared across all gateway
replicas. Note that keys survive restarts, the JWKS endpoint is
consistent across replicas, and keys rotate on roughly a 90-day cadence
so users can reason about JWKS cache lifetimes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

Deploy Preview for permitio-docs ready!

Name Link
🔨 Latest commit ca8ab6f
🔍 Latest deploy log https://app.netlify.com/projects/permitio-docs/deploys/6a21461d95363900082fe2b8
😎 Deploy Preview https://deploy-preview-623--permitio-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dshoen619 dshoen619 self-assigned this Apr 19, 2026
Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

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

see comments.

Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Fixes 8 inaccuracies vs. the implementation in agent-security main:

- Sequence diagram now shows shared-key load (not ephemeral generation)
- aud row documents canonicalization (lowercase host, strip trailing slashes)
- iat/nbf rows show 30s leeway; adds clock-tolerance note for verifiers
- Drops misleading "enables replay detection" from jti row; adds opt-in
  replay-protection guidance in the verifier section
- Verifier snippet now guards missing/non-string headers and the Bearer
  prefix, and sets clockTolerance: 30
- Key rotation callout: encryption-at-rest is conditional on vault;
  90-day cadence is a warning, not automatic rotation
- Configuration table adds GATEWAY_JWT_REQUIRE_VAULT and TTL bounds

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dshoen619 dshoen619 requested a review from zeevmoney May 4, 2026 09:05
Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

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

Automated Review - the PR looks clean, found nothing.

Copilot AI review requested due to automatic review settings June 2, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds documentation to the MCP Gateway architecture page describing how the gateway authenticates itself to upstream MCP servers using a short-lived, gateway-signed JWT (X-Gateway-Auth) and how upstreams can verify it via the gateway’s JWKS endpoint.

Changes:

  • Updated the System Architecture Overview diagram to label the Gateway → Upstream edge with X-Gateway-Auth and show an optional upstream verification flow to the gateway JWKS endpoint.
  • Updated the Data Flow table to mention the signed X-Gateway-Auth JWT and link to the new section.
  • Added a new “Upstream Authentication (Gateway JWT)” section with flow explanation, claims table, verification snippet, key rotation notes, and configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx
Comment thread docs/permit-mcp-gateway/architecture.mdx
Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

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

See comments.

Comment thread docs/permit-mcp-gateway/architecture.mdx Outdated
Comment thread docs/permit-mcp-gateway/architecture.mdx
dshoen619 and others added 2 commits June 4, 2026 12:22
- Data Flow diagram edge now mentions the signed X-Gateway-Auth JWT, matching the table row (Copilot, Zeev)
- Sequence-diagram claim list includes nbf (Zeev)
- Reworded "JWT signing (per-request)" note to reflect lazy caching/re-sign-near-expiry (Copilot)
- Use {...} placeholders instead of angle brackets in the sequence diagram so they don't render as HTML (Copilot)
- Use ASCII hyphen instead of Unicode minus in the iat/nbf claim rows (Copilot)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dshoen619 dshoen619 requested a review from zeevmoney June 4, 2026 09:41
Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

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

Automated Review - the PR looks clean, found nothing.

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.

3 participants