Commit 1ec78af
feat: add --auth-key CLI flag and wire auth into HTTP server (#48)
The AuthStore existed but was never integrated into the server or
exposed via CLI. This meant auth was effectively dead code.
Changes:
- Add --auth-key <key> CLI flag that registers an admin API key
- Wire AuthStore into Database struct so it's accessible from server
- HTTP server now enforces auth on all data endpoints when enabled
- /health and /metrics remain public (no key needed)
- All /db/*, /collections, /branch/*, /cdc/* require X-Api-Key
- Add 401 Unauthorized HTTP status to error handler
- Unknown CLI flags now error immediately instead of being silently ignored
No auth configured → open access (dev mode), same as before.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent befe436 commit 1ec78af
3 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1471 | 1471 | | |
1472 | 1472 | | |
1473 | 1473 | | |
| 1474 | + | |
1474 | 1475 | | |
1475 | 1476 | | |
1476 | 1477 | | |
| |||
1503 | 1504 | | |
1504 | 1505 | | |
1505 | 1506 | | |
| 1507 | + | |
1506 | 1508 | | |
1507 | 1509 | | |
1508 | 1510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| |||
101 | 109 | | |
102 | 110 | | |
103 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| |||
760 | 769 | | |
761 | 770 | | |
762 | 771 | | |
| 772 | + | |
763 | 773 | | |
764 | 774 | | |
765 | 775 | | |
| |||
0 commit comments