Commit 21b5af0
docs: Clarify HTTP endpoint auth is optional, not required (#4562)
## Summary
All `/v1/database` routes go through `anon_auth_middleware`, which
allocates a new anonymous identity when no `Authorization` header is
provided. The docs previously marked many endpoints as requiring auth
(`Required Headers`) when they actually accept anonymous requests.
## Code audit
Traced through `anon_auth_middleware` in `crates/client-api/src/auth.rs`
and each route handler in `crates/client-api/src/routes/database.rs`:
| Route | Old docs | Actual behavior | New docs |
|---|---|---|---|
| `POST /v1/database` (publish) | Required | Optional (anon creates new
DB) | Optional + explanation |
| `PUT /v1/database/:id` (publish) | Required | Optional (ownership
checked) | Optional + explanation |
| `GET /v1/database/:id` (info) | No auth section | No auth used |
Unchanged |
| `DELETE /v1/database/:id` | Required | Optional (ownership checked) |
Optional + explanation |
| `GET .../names` | No auth section | No auth used | Unchanged |
| `POST .../names` | Required | Optional (TLD ownership checked) |
Optional + explanation |
| `PUT .../names` | Required | Optional (ownership checked) | Optional +
explanation |
| `GET .../identity` | No auth section | No auth used | Unchanged |
| `GET .../subscribe` (WS) | Optional | Optional | Unchanged (already
correct) |
| `POST .../call/:reducer` | Required | Optional (identity passed to
reducer) | Optional + explanation |
| `GET .../schema` | No auth section | No permission check | Added
Optional section |
| `GET .../logs` | Required | Optional (ownership checked) | Optional +
explanation |
| `POST .../sql` | Required | Optional (RLS enforces access) | Optional
+ explanation |
Routes that genuinely require auth (`POST /v1/identity/websocket-token`,
`GET /v1/identity/:id/verify`) use `SpacetimeAuthRequired` and are
unchanged.
## Changes
- `authorization.md`: Added paragraph explaining anonymous access for
all `/v1/database` endpoints
- `database.md`: Changed `Required Headers` to `Optional Headers` for 8
endpoints, with per-endpoint explanations of anonymous behavior
- `database.md`: Added new `Optional Headers` section to `/schema`
endpoint (previously undocumented)
---------
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>1 parent 2149325 commit 21b5af0
3 files changed
Lines changed: 34 additions & 30 deletions
File tree
- docs/docs/00300-resources/00200-reference/00200-http-api
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
Lines changed: 0 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | 64 | | |
87 | 65 | | |
88 | 66 | | |
| |||
Lines changed: 32 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
126 | | - | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
| 136 | + | |
| 137 | + | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| |||
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
150 | | - | |
| 156 | + | |
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
| 162 | + | |
| 163 | + | |
156 | 164 | | |
157 | 165 | | |
158 | 166 | | |
| |||
180 | 188 | | |
181 | 189 | | |
182 | 190 | | |
183 | | - | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
188 | 196 | | |
| 197 | + | |
| 198 | + | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| |||
249 | 259 | | |
250 | 260 | | |
251 | 261 | | |
252 | | - | |
| 262 | + | |
253 | 263 | | |
254 | 264 | | |
255 | 265 | | |
256 | 266 | | |
257 | 267 | | |
| 268 | + | |
| 269 | + | |
258 | 270 | | |
259 | 271 | | |
260 | 272 | | |
| |||
271 | 283 | | |
272 | 284 | | |
273 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
274 | 294 | | |
275 | 295 | | |
276 | 296 | | |
| |||
409 | 429 | | |
410 | 430 | | |
411 | 431 | | |
412 | | - | |
| 432 | + | |
413 | 433 | | |
414 | 434 | | |
415 | 435 | | |
416 | 436 | | |
417 | 437 | | |
| 438 | + | |
| 439 | + | |
418 | 440 | | |
419 | 441 | | |
420 | 442 | | |
| |||
425 | 447 | | |
426 | 448 | | |
427 | 449 | | |
428 | | - | |
| 450 | + | |
429 | 451 | | |
430 | 452 | | |
431 | 453 | | |
432 | 454 | | |
433 | 455 | | |
| 456 | + | |
| 457 | + | |
434 | 458 | | |
435 | 459 | | |
436 | 460 | | |
| |||
0 commit comments