Skip to content

Commit 3334e40

Browse files
authored
docs: add docs for introspection auth bypass (#166)
* feat: add docs for introspection auth bypass * fix: use better wording to describe default behaviour * chore: update docs to latest feature changes + improve wording * chore: add new config settings to global config
1 parent 6b6e615 commit 3334e40

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

docs/router/authentication-and-authorization.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,54 @@ The router configuration facilitates the setup of multiple JWKS (JSON Web Key Se
5656
5757
For more information on the attributes, visit the auth configuration parameter section page [here](/router/configuration#authentication).
5858
59+
### Disabling Authentication for Introspection Operations
60+
61+
Cosmo Router supports bypassing authentication for introspection queries.
62+
63+
This is useful, for example, when you want to configure client tooling from within a secured environment without requiring authentication tokens.
64+
Instead of having to disable authentication altogether, this feature allows you to keep the configuration as close to production as possible while still using introspection queries easily.
65+
Additionally, you can define a dedicated secret to authenticate introspection queries.
66+
67+
<Warning>
68+
This feature is meant to be used in secure, internal environments. It is not recommended for use in a production environment.
69+
By default, introspection queries are not excluded from authentication.
70+
</Warning>
71+
72+
To enable this feature, add the following section to your router configuration:
73+
74+
<CodeGroup>
75+
```yaml config.yaml
76+
authentication:
77+
ignore_introspection: true # default is false
78+
# other auth settings here
79+
```
80+
</CodeGroup>
81+
82+
Now, when you send an introspection query, you won't need to provide an authentication token.
83+
84+
```bash
85+
curl -X POST http://localhost:3002/graphql \
86+
--header "Content-Type: application/json" \
87+
--data '{"query": "{ __schema { types { name } } }"}'
88+
```
89+
90+
Optionally, you can set a dedicated secret for introspection queries.
91+
92+
<CodeGroup>
93+
```yaml config.yaml
94+
introspection:
95+
secret: 'dedicated_secret_for_introspection'
96+
```
97+
</CodeGroup>
98+
99+
When a secret is set, you must include it in the `Authorization` header (without a Bearer prefix).
100+
101+
```bash
102+
curl -X POST http://localhost:3002/graphql \
103+
--header "Content-Type: application/json" \
104+
--header "Authorization: dedicated_secret_for_introspection" \
105+
--data '{"query": "{ __schema { types { name } } }"}'
106+
```
59107

60108

61109
## Old Router configuration (\< 0.168.1)

docs/router/configuration.mdx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ The following sections describe each configuration in detail with all available
134134
| CONTROLPLANE_URL | controlplane_url | <Icon icon="square-check" iconType="solid" /> | The controlplane url. Not required when a static execution config is provided. | https://cosmo-cp.wundergraph.com |
135135
| PLAYGROUND_ENABLED | playground_enabled | <Icon icon="square" /> | Enables the GraphQL playground on (`$LISTEN_ADDR/`) | true |
136136
| PLAYGROUND_PATH | playground_path | <Icon icon="square" /> | The path where the playground is served | "/" |
137-
| INTROSPECTION_ENABLED | introspection_enabled | <Icon icon="square" /> | Enables the GraphQL introspection | true |
137+
| INTROSPECTION_ENABLED | introspection_enabled | <Icon icon="square" /> | Enables the GraphQL introspection (deprecated, use `introspection.enabled` instead) | true |
138138
| QUERY_PLANS_ENABLED | query_plans_enabled | <Icon icon="square" /> | The Router can return Query plans as part of the response, which might be useful to understand the execution. | true |
139139
| LOG_LEVEL | log_level | <Icon icon="square" /> | The log level to use. Allowed levels are `"debug"`, `"info"`, `"warn"`, `"error"`, `"panic"`, `"fatal"`. | info |
140140
| JSON_LOG | json_log | <Icon icon="square" /> | Render the log output in JSON format (true) or human readable (false) | true |
@@ -173,6 +173,11 @@ liveness_check_path: "/health/live"
173173
router_config_path: ""
174174
```
175175

176+
<Warning>
177+
`introspection_enabled` is a deprecated flag.
178+
Please use `introspection.enabled` instead.
179+
</Warning>
180+
176181
## Config watcher hot reloading
177182

178183
The router is capable of reloading itself using an updated config without a full process restart. You can trigger a reload in one of two ways:
@@ -304,6 +309,25 @@ graph:
304309
token: "<your-graph-token>"
305310
```
306311

312+
## Introspection
313+
314+
Overall configuration for managing introspection queries on this Router.
315+
316+
| Environment Variable | YAML | Required | Description | Default Value |
317+
| --------------------- | -------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
318+
| INTROSPECTION_ENABLED | enabled | <Icon icon="square" /> | Enable or disable introspection queries | true |
319+
| INTROSPECTION_SECRET | secret | <Icon icon="square" /> | Optional, dedicated secret used for instrospection authentication. Only used when `authentication.ignore_introspection` is set to `true`. | |
320+
321+
### Example YAML config:
322+
323+
```yaml config.yaml
324+
version: "1"
325+
326+
introspection:
327+
enabled: true
328+
secret: "dedicated_secret_for_introspection"
329+
```
330+
307331
## MCP (Model Context Protocol)
308332

309333
The Model Context Protocol (MCP) server allows AI models to discover and interact with your GraphQL API in a secure way.
@@ -1506,6 +1530,21 @@ authentication:
15061530
name: X-Authorization
15071531
```
15081532

1533+
### Bypass Introspection Authentication
1534+
1535+
This is useful when you want to bypass authentication for introspection queries,
1536+
for example let certain tools introspect the schema without requiring authentication token.
1537+
1538+
<Warning>
1539+
This feature is meant to be used in secure, internal environments. It is not recommended for use in a production environment.
1540+
By default, introspection queries are not excluded from authentication.
1541+
Also consider setting `introspection.secret` for a static secret dedicated to introspection queries.
1542+
</Warning>
1543+
1544+
| Environment Variable | YAML | Required | Description | Default Value |
1545+
| -------------------- | -------------------- | ---------------------- | ----------------------------------- | ---------------- |
1546+
| | ignore_introspection | <Icon icon="square" /> | Bypass introspection authentication | false |
1547+
15091548
### Old Authentication Config (Router Version \< 0.XXX.X)
15101549

15111550
### Provider

docs/router/security/hardening-guide.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ By default introspection is enabled. The following configuration should be appli
1212

1313
<CodeGroup>
1414
```yaml router.yaml
15-
introspection_enabled: false
15+
introspection:
16+
enabled: false
1617
```
1718
</CodeGroup>
1819

0 commit comments

Comments
 (0)