You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enforce bearer auth on all /api/* routes and add tests
Apply HTTP bearer token authorization to every /api/* request in the
cloudsession package by using Hono's built-in bearerAuth middleware at
the app.use("/api/*") level. This replaces the per-route
isAuthorizedAdminRequest guard with a single middleware that protects all
API endpoints uniformly.
Key changes:
- cloudsession/src/index.tsx: add bearerAuth middleware (hono/bearer-auth)
to app.use("/api/*"). Token validated against SESSIONS_RPC_SHARED_KEY;
if unset, all API requests are rejected. Remove the now-redundant
isAuthorizedAdminRequest helper and its manual check in GET /api/sessions.
- opencode/src/share/share-next.ts: change rpcHeaders() to emit the
standard Authorization: Bearer <token> header instead of the custom
x-opencode-share-key header. Spread rpcHeaders() into all three HTTP
transport fetch calls (POST /api/share, POST /api/share/:id/sync,
DELETE /api/share/:id).
- cloudsession/src/api.test.ts: add SESSIONS_RPC_SHARED_KEY to the test
env, pass Authorization: Bearer in every request helper, and add a new
"API Authorization" suite with 9 tests covering unauthenticated (401),
wrong-token (401), and authorised (200) scenarios for key endpoints.
- cloudsession/src/index.test.ts: add SESSIONS_RPC_SHARED_KEY to the test
env and include Authorization: Bearer headers in all API requests.
- packages/opencode/test/share/share-next.test.ts: new test file with 5
source-level assertions verifying the bearer header format and that every
HTTP fetch call in share-next.ts spreads rpcHeaders().
https://claude.ai/code/session_01HbjvMV8GaSbrjysBmUwM8P
0 commit comments