Enable auth in SignalDesk
SignalDesk ships with auth off so it runs with zero config. Use this skill to
add Convex Auth. The default path uses the Password provider so no OAuth keys are
needed. Follow docs/AUTH.md in the repo as the source of truth and keep changes
minimal.
Before you start
Confirm with the user:
- Provider: Password (default, no keys) or an OAuth provider like GitHub or Google (needs client id and secret).
- Whether all functions should require sign in, or only some.
Steps
Install packages:
npm install @convex-dev/auth @auth/coreRun the auth setup helper to generate keys and env vars:
npx @convex-dev/authCreate
convex/auth.tsexportingconvexAuthwith the chosen provider.Spread
authTablesintoconvex/schema.ts.Add
auth.addHttpRoutes(http)inconvex/http.ts, keeping the existingregisterStaticRoutescall.Swap
ConvexProviderforConvexAuthProviderinsrc/main.tsx.Add a sign in form gated by
<Authenticated>and<Unauthenticated>.Protect Convex functions with
getAuthUserId(ctx)where needed.Set
VITE_AUTH_ENABLED=truein.env.local.
Rules
- Keep argument and return validators on every Convex function.
- Do not store secrets in the database or in frontend env files. OAuth secrets
go in Convex env vars via
npx convex env set. - Run
npm run typecheckandnpm run lintafter wiring it up. - Verify: sign up, sign out, sign in, and confirm a protected function rejects an unauthenticated call.
References
- docs/AUTH.md in this repo
- https://labs.convex.dev/auth
- https://labs.convex.dev/auth/setup
- https://docs.convex.dev/auth/functions-auth