Skip to content

Commit 29b6222

Browse files
committed
Add JWT integration section and fix config links
1 parent 6a5666b commit 29b6222

File tree

3 files changed

+43
-40
lines changed

3 files changed

+43
-40
lines changed

packages/web/docs/src/content/router/configuration/authorization.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The `authorization` configuration lets you control fine-grained access to your G
88
directives. This allows you to restrict which fields authenticated users can access based on their
99
authentication status or specific scopes.
1010

11+
For practical examples and a guide to authorization concepts, see
12+
**["Authorization"](../security/authorization)** in the documentation.
13+
1114
## How Authorization Works
1215

1316
The router supports two modes for handling unauthorized field access:

packages/web/docs/src/content/router/configuration/index.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Some configuration variables can be overridden at runtime using
1313
This page covers all the main configuration options available. Each option links to a detailed page
1414
that explains how to use that feature.
1515

16-
- [`authorization`](./authorization): Define field-level access control using directives.
17-
- [`cors`](./cors): Control cross-origin requests to your API.
18-
- [`csrf`](./csrf): Protect against cross-site request forgery attacks.
19-
- [`headers`](./headers): Modify HTTP headers between clients and subgraphs.
20-
- [`http`](./http): Set the host and port for your router.
21-
- [`jwt`](./jwt): Add JWT-based authentication to secure your endpoint.
22-
- [`log`](./log): Control what the router logs and how it formats log messages.
23-
- [`override_subgraph_urls`](./override_subgraph_urls): Route requests to different
16+
- [`authorization`](./configuration/authorization): Define field-level access control using directives.
17+
- [`cors`](./configuration/cors): Control cross-origin requests to your API.
18+
- [`csrf`](./configuration/csrf): Protect against cross-site request forgery attacks.
19+
- [`headers`](./configuration/headers): Modify HTTP headers between clients and subgraphs.
20+
- [`http`](./configuration/http): Set the host and port for your router.
21+
- [`jwt`](./configuration/jwt): Add JWT-based authentication to secure your endpoint.
22+
- [`log`](./configuration/log): Control what the router logs and how it formats log messages.
23+
- [`override_subgraph_urls`](./configuration/override_subgraph_urls): Route requests to different
2424
subgraph URLs dynamically.
25-
- [`override_labels`](./override_labels): Dynamically activate or deactivate
25+
- [`override_labels`](./configuration/override_labels): Dynamically activate or deactivate
2626
progressive override labels.
27-
- [`query_planner`](./query_planner): Add safety limits and debugging for query
27+
- [`query_planner`](./configuration/query_planner): Add safety limits and debugging for query
2828
planning.
29-
- [`supergraph`](./supergraph): Tell the router where to find your supergraph schema.
30-
- [`traffic_shaping`](./traffic_shaping): Manage connection pooling and request
29+
- [`supergraph`](./configuration/supergraph): Tell the router where to find your supergraph schema.
30+
- [`traffic_shaping`](./configuration/traffic_shaping): Manage connection pooling and request
3131
handling to subgraphs.

packages/web/docs/src/content/router/security/authorization.mdx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@ When a GraphQL request comes to the router, it goes through these steps:
2020

2121
The key insight is that authorization happens **before** your subgraphs are even called. This protects sensitive fields at the router level.
2222

23+
## Integration with JWT Authentication
24+
25+
Authorization directives work alongside your [JWT authentication setup](./jwt-authentication.mdx). Here's the flow:
26+
27+
1. **Client sends request** with JWT token in the `Authorization` header
28+
2. **Router validates JWT** using your configured JWKS provider
29+
3. **Router extracts scopes** from the JWT claims (`scope` field)
30+
4. **Router checks authorization directives** against the extracted scopes
31+
5. **Query proceeds or fails** based on authorization result
32+
33+
**Configuration example:**
34+
35+
```yaml filename="router.config.yaml"
36+
jwt:
37+
require_authentication: false # Allow anonymous requests
38+
jwks_providers:
39+
- source: remote
40+
url: https://your-auth-provider.com/.well-known/jwks.json
41+
42+
authorization:
43+
directives:
44+
enabled: true
45+
unauthorized:
46+
mode: filter # Or 'reject' for stricter enforcement
47+
```
48+
49+
With this setup, your GraphQL API allows both anonymous and authenticated requests, but authorization directives control which fields each user can access.
50+
2351
## The Two Authorization Directives
2452
2553
### `@authenticated`
@@ -257,34 +285,6 @@ query {
257285
}
258286
```
259287

260-
## Integration with JWT Authentication
261-
262-
Authorization directives work alongside your [JWT authentication setup](./jwt-authentication.mdx). Here's the flow:
263-
264-
1. **Client sends request** with JWT token in the `Authorization` header
265-
2. **Router validates JWT** using your configured JWKS provider
266-
3. **Router extracts scopes** from the JWT claims (`scope` field)
267-
4. **Router checks authorization directives** against the extracted scopes
268-
5. **Query proceeds or fails** based on authorization result
269-
270-
**Configuration example:**
271-
272-
```yaml filename="router.config.yaml"
273-
jwt:
274-
require_authentication: false # Allow anonymous requests
275-
jwks_providers:
276-
- source: remote
277-
url: https://your-auth-provider.com/.well-known/jwks.json
278-
279-
authorization:
280-
directives:
281-
enabled: true
282-
unauthorized:
283-
mode: filter # Or 'reject' for stricter enforcement
284-
```
285-
286-
With this setup, your GraphQL API allows both anonymous and authenticated requests, but authorization directives control which fields each user can access.
287-
288288

289289
## Specification
290290

0 commit comments

Comments
 (0)