fix: add auth guards to providers, update, and health API (#61)#69
Conversation
…te (#61) - Add requireUser() shared helper in src/server/auth/ - Guard all providers.* actions (list, connect, disconnect, startOauth, finishOauth, getAvailableModelsForUser) - Guard all update.* actions (checkForUpdate, pull, restart) - Add requireAuth() to GET /api/system/health - Migrate mcps.ts from local ensureAuthenticated to shared requireUser Unauthenticated callers now receive UNAUTHORIZED / 401 instead of accessing provider credentials, OAuth flows, Docker operations, and infrastructure health data.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughA new shared 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Closes #61
What
Adds authentication checks to 10 action handlers and 1 API route that were callable without authentication due to Astro middleware deliberately skipping auth for
/_actions/and/api/.Changes
src/server/auth/requireUser.ts— shared typed auth guard (requireUser(context) → User) extracted from 3 duplicateensureAuthenticatedcopiesproviders.ts: Guards all 6 handlers (list, connect, disconnect, startOauth, finishOauth, getAvailableModelsForUser) — auth checked before cache, OpenCode API, or OAuth callsupdate.ts: Guards all 3 handlers (checkForUpdate, pull, restart) — auth checked before Docker operationshealth.ts: AddsrequireAuth(cookies)→ returns 401 before any DB queries leak queue/project/infrastructure datamcps.ts: Migrated from localensureAuthenticatedto sharedrequireUser(no behavior change)Impact
UNAUTHORIZED(actions) / 401 (API) instead of accessing provider credentials, OAuth flows, Docker operations, and infrastructure healthauth.tsandsetup.tsintentionally untouched (public login/first-run setup)Validation
pnpm exec biome checkpasses on all changed filesgit diff --checkpasses (no whitespace errors)Summary by CodeRabbit