Skip to content

Commit 9573971

Browse files
jhrozekclaude
andauthored
Restructure backend auth docs for balanced pattern coverage (#554)
* Restructure backend auth docs for balanced pattern coverage The backend-auth.mdx page was heavily weighted toward token exchange while the embedded authorization server and static credentials got minimal coverage. Restructure so all three backend auth patterns get equal treatment with their own sections, diagrams, and guidance. Maintain the page separation: auth-framework.mdx focuses on client-to-MCP-server authentication, backend-auth.mdx focuses on MCP-server-to-backend authentication. The embedded authorization server spans both concerns, so each page covers its respective perspective. Key changes to backend-auth.mdx: - Add static credentials section with Vault cross-reference - Add embedded authorization server section with OAuth flow diagram, key characteristics, and tsid-based token storage/forwarding detail - Reorganize token exchange content under "Token exchange in depth" - Replace verbose choosing-the-right-model bullets with decision table - Broaden front matter, intro, and benefits to cover all patterns Key changes to auth-framework.mdx: - Trim embedded auth server section to focus on client-facing flow - Add cross-reference to backend-auth.mdx for backend token details - Fix "Why ToolHive centralizes" to attribute per-server cost to centralization and registration/federation gaps to the auth server * Fix inaccurate wording in backend auth docs Address PR review feedback: - Add static credentials to frontmatter description - Clarify credential delivery covers headers and env vars - Scope DCR descriptions to ToolHive registration * Address review comments * Update session storage warning to reflect Redis support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b8fc5bd commit 9573971

3 files changed

Lines changed: 229 additions & 157 deletions

File tree

docs/toolhive/concepts/auth-framework.mdx

Lines changed: 28 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description:
77
This document explains the concepts behind ToolHive's authentication and
88
authorization framework, which secures MCP servers by verifying client identity
99
and controlling access to resources. You'll learn how these systems work
10-
together, why they're designed this way, and the benefits of this approach.
10+
together, the reasoning behind their design, and the benefits of this approach.
1111

1212
:::info[Scope of this documentation]
1313

@@ -63,18 +63,20 @@ significant operational challenges:
6363
its own token validation and scope management, duplicating security-critical
6464
logic across servers.
6565

66-
ToolHive addresses these challenges by centralizing authentication and
67-
authorization in its proxy layer. You configure ToolHive with your identity
68-
provider and write Cedar policies for fine-grained authorization—individual MCP
69-
servers don't need to implement token validation or scope management.
70-
71-
With the [embedded authorization server](#embedded-authorization-server),
72-
ToolHive can also manage interactive token acquisition. The proxy exposes
73-
standard OAuth endpoints and handles the full OAuth web flow—clients don't need
74-
to obtain or manage tokens externally. ToolHive delegates authentication to an
75-
upstream identity provider and issues its own tokens, giving MCP clients a
76-
spec-compliant OAuth experience while centralizing the complexity of client
77-
registration and token management.
66+
ToolHive addresses the per-server implementation cost by centralizing
67+
authentication and authorization in its proxy layer. You configure ToolHive with
68+
your identity provider and write Cedar policies for fine-grained
69+
authorization—individual MCP servers don't need to implement token validation or
70+
scope management.
71+
72+
The [embedded authorization server](#embedded-authorization-server) addresses
73+
the remaining challenges. It exposes standard OAuth endpoints and handles the
74+
full OAuth web flow, eliminating the client registration burden through Dynamic
75+
Client Registration (DCR) and solving the federation gap by obtaining tokens
76+
directly from external providers like GitHub or Atlassian. ToolHive delegates
77+
authentication to the upstream provider and issues its own tokens, giving MCP
78+
clients a spec-compliant OAuth experience while centralizing the complexity of
79+
token acquisition and management.
7880

7981
## Authentication framework
8082

@@ -182,94 +184,26 @@ deployments using the ToolHive Operator.
182184

183185
:::
184186

185-
This approach is designed for MCP servers that accept `Authorization: Bearer`
186-
tokens and is particularly useful when you want ToolHive to handle the full
187-
OAuth flow rather than requiring clients to obtain tokens independently.
188-
189-
#### How the embedded authorization server works
190-
191-
The embedded authorization server runs in-process within the ToolHive proxy.
192-
When a client connects, the following flow occurs:
187+
From the client's perspective, the embedded authorization server provides a
188+
standard OAuth 2.0 experience:
193189

194190
1. If the client is not yet registered, it registers via Dynamic Client
195191
Registration (DCR), receiving a `client_id` and `client_secret`.
196192
2. The client is directed to the ToolHive authorization endpoint.
197-
3. The proxy redirects the client to the upstream identity provider for
198-
authentication.
199-
4. The user authenticates with the upstream identity provider (for example,
200-
signing in with Google or GitHub).
201-
5. The upstream identity provider redirects back to the proxy with an
202-
authorization code.
203-
6. The embedded authorization server exchanges the authorization code for tokens
204-
with the upstream identity provider.
205-
7. The embedded authorization server issues its own JWT to the client, signed
206-
with keys you configure.
207-
8. The client includes this JWT as a `Bearer` token in the `Authorization`
193+
3. ToolHive redirects the client to the upstream identity provider for
194+
authentication (for example, signing in with GitHub or Atlassian).
195+
4. ToolHive exchanges the authorization code for upstream tokens and issues its
196+
own JWT to the client, signed with keys you configure.
197+
5. The client includes this JWT as a `Bearer` token in the `Authorization`
208198
header on subsequent requests.
209-
9. The proxy validates the JWT, retrieves the upstream token, and forwards
210-
requests to the MCP server.
211-
212-
```mermaid
213-
sequenceDiagram
214-
participant Client
215-
participant Proxy as ToolHive Proxy
216-
participant IdP as Upstream IdP
217-
participant MCP as MCP Server
218-
219-
Client->>Proxy: POST /oauth/register (DCR)
220-
Proxy-->>Client: client_id + client_secret
221-
Client->>Proxy: Connect to MCP server
222-
Proxy-->>Client: Redirect to /oauth/authorize
223-
Client->>Proxy: GET /oauth/authorize
224-
Proxy-->>Client: Redirect to upstream IdP
225-
Client->>IdP: Authenticate
226-
IdP-->>Client: Redirect with authorization code
227-
Client->>Proxy: GET /oauth/callback?code=...
228-
Proxy->>IdP: Exchange code for tokens
229-
IdP-->>Proxy: Upstream tokens
230-
Proxy-->>Client: Issue ToolHive JWT
231-
Client->>Proxy: MCP request with Bearer token
232-
Proxy->>Proxy: Validate JWT
233-
Proxy->>MCP: Forward request
234-
MCP-->>Proxy: Response
235-
Proxy-->>Client: Response
236-
```
237199

238-
#### Key characteristics
239-
240-
- **In-process execution:** The authorization server runs within the ToolHive
241-
proxy—no separate infrastructure or sidecar containers needed.
242-
- **Configurable signing keys:** JWTs are signed with keys you provide,
243-
supporting key rotation for zero-downtime updates.
244-
- **Flexible upstream providers:** Supports both OIDC providers (with automatic
245-
endpoint discovery) and OAuth 2.0 providers (with explicit endpoint
246-
configuration).
247-
- **Configurable token lifespans:** Access tokens, refresh tokens, and
248-
authorization codes have configurable durations with sensible defaults.
249-
- **Dynamic Client Registration (DCR):** Supports OAuth 2.0 Dynamic Client
250-
Registration (RFC 7591), allowing MCP clients to register automatically
251-
without manual configuration at the identity provider.
252-
- **Direct upstream redirect:** The embedded authorization server redirects
253-
clients directly to the upstream provider for authentication (for example,
254-
GitHub or Atlassian).
255-
- **Single upstream provider:** Currently supports one upstream identity
256-
provider per configuration.
257-
258-
:::info[Chained authentication not yet supported]
259-
260-
The embedded authorization server redirects clients directly to the upstream
261-
provider. This means the upstream provider must be the service whose API the MCP
262-
server calls. Chained authentication—where a client authenticates with a
263-
corporate IdP like Okta, which then federates to an external provider like
264-
GitHub—is not yet supported. If your deployment requires this pattern, consider
265-
using [token exchange](./backend-auth.mdx#same-idp-with-token-exchange) with a
266-
federated identity provider instead.
267-
268-
:::
200+
Behind the scenes, ToolHive stores the upstream tokens and uses them to
201+
authenticate MCP server requests to external APIs. For the complete flow,
202+
including token storage and forwarding, see
203+
[Embedded authorization server](./backend-auth.mdx#embedded-authorization-server).
269204

270-
For guidance on choosing the right backend authentication pattern for your MCP
271-
servers, see
272-
[Choosing the right backend authentication model](./backend-auth.mdx#choosing-the-right-backend-authentication-model).
205+
For Kubernetes setup instructions, see
206+
[Set up embedded authorization server authentication](../guides-k8s/auth-k8s.mdx#set-up-embedded-authorization-server-authentication).
273207

274208
### Identity providers
275209

0 commit comments

Comments
 (0)