Skip to content

Commit c441da0

Browse files
committed
docs(runbook): add peer auth token rotation and verification steps
1 parent 67429c9 commit c441da0

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

docs/host-bit-relay.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,60 @@ bit relay serve relay+https://<your-worker>.workers.dev
141141
bit relay sync push relay+https://<your-worker>.workers.dev
142142
```
143143

144+
## Runbook: Rotate `RELAY_PEER_AUTH_TOKEN`
145+
146+
Use this when peer cache APIs must be re-keyed without breaking relay operations.
147+
148+
### 1) Generate a new token
149+
150+
```bash
151+
NEW_TOKEN="$(openssl rand -hex 32)"
152+
echo "$NEW_TOKEN"
153+
```
154+
155+
### 2) Update Cloudflare secret
156+
157+
```bash
158+
printf '%s' "$NEW_TOKEN" | wrangler secret put RELAY_PEER_AUTH_TOKEN
159+
```
160+
161+
### 3) Roll out to every peer relay
162+
163+
Every peer process must run with the same token value:
164+
165+
```bash
166+
RELAY_PEER_AUTH_TOKEN="$NEW_TOKEN"
167+
```
168+
169+
For this repository's helper scripts, include it in the relay start env (for example on
170+
sprites/exe).
171+
172+
### 4) Verify auth boundary (must pass)
173+
174+
```bash
175+
BASE="https://<relay>.workers.dev"
176+
177+
# no auth -> 401
178+
curl -i "$BASE/api/v1/cache/exchange/discovery"
179+
180+
# with auth -> 200
181+
curl -i -H "authorization: Bearer $NEW_TOKEN" \
182+
"$BASE/api/v1/cache/exchange/discovery"
183+
```
184+
185+
Also verify issue cache API:
186+
187+
```bash
188+
curl -i "$BASE/api/v1/cache/issues/pull?room=main&after=0&limit=1"
189+
curl -i -H "authorization: Bearer $NEW_TOKEN" \
190+
"$BASE/api/v1/cache/issues/pull?room=main&after=0&limit=1"
191+
```
192+
193+
### 5) Invalidate old token
194+
195+
After all peers are updated, old token requests must return `401`. Run a final check against known
196+
peers and remove any leftover old-token env values.
197+
144198
## Architecture
145199

146200
```

0 commit comments

Comments
 (0)