Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ntedvs/ganzo/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Stanzo uses Convex Auth for authentication, which provides:- GitHub OAuth integration
- User session management
- Automatic database tables for users, sessions, and accounts
- Type-safe authentication checks in queries and mutations
Convex Auth is built on top of Auth.js (formerly NextAuth.js) and integrates seamlessly with Convex’s backend.
Setup
Authentication is configured in two files:1. Auth Configuration (convex/auth.ts)
auth: HTTP handler for OAuth callbackssignIn/signOut: Mutations to start/end user sessionsstore: Internal mutation for session storageisAuthenticated: Helper to check if user is logged in
2. Auth Config (convex/auth.config.ts)
CONVEX_SITE_URL environment variable should point to your Convex deployment.
Environment Variables
For GitHub OAuth to work, you need to set these in your Convex dashboard:Database Schema
Convex Auth automatically adds these tables to your schema:users: User profiles (name, email, image)authSessions: Active user sessionsauthAccounts: Links users to OAuth providers (GitHub, etc.)
Authentication Checks
In Mutations
UsegetAuthUserId() to get the current user’s ID and enforce authentication:
getAuthUserId(ctx)returnsId<"users"> | null- If the user is logged in, it returns their user ID
- If not logged in, it returns
null
In Queries
Queries can also check authentication to filter data:- Returns an empty array for logged-out users
- Returns only the current user’s debates for logged-in users
Ownership Verification
When modifying resources, verify the current user owns them:Returning “Not found” instead of “Unauthorized” prevents leaking information about whether a debate ID exists.
Frontend Integration
Sign In
Trigger GitHub OAuth flow:- Redirects user to GitHub
- User authorizes your app
- GitHub redirects back to your app
- Session is created in Convex
Sign Out
Get Current User
Session Management
Session Lifetime
Convex Auth sessions are:- Stored in HTTP-only cookies (secure against XSS)
- Valid for 30 days by default
- Automatically refreshed on activity
Session Storage
Sessions are stored in theauthSessions table:
getAuthUserId(ctx) is called, Convex:
- Reads the session token from the HTTP cookie
- Looks up the session in
authSessions - Verifies it hasn’t expired
- Returns the associated
userId
Multiple Devices
Users can be logged in on multiple devices simultaneously. Each device has its own session in theauthSessions table.
Security Considerations
HTTPS Required
GitHub OAuth requires HTTPS. In development:- Convex provides
https://<your-deployment>.convex.siteautomatically - Your frontend should use the Convex dev server or ngrok
Token Storage
Session tokens are:- Stored in HTTP-only cookies (inaccessible to JavaScript)
- Sent only over HTTPS
- Scoped to your domain
Authorization Pattern
Always follow this pattern in mutations:- Only logged-in users can perform actions
- Users can only modify their own resources
- Resource existence isn’t leaked to unauthorized users
Troubleshooting
”Not authenticated” errors
Check:AUTH_GITHUB_IDandAUTH_GITHUB_SECRETare set in Convex dashboard- GitHub OAuth app callback URL matches your Convex deployment
- User has completed the OAuth flow
Sessions not persisting
Check:- Cookies are enabled in browser
- Your frontend is served over HTTPS (or localhost in dev)
- Cookie domain matches your deployment URL
”providers is not iterable” error
Ensureconvex/auth.config.ts exports a default export: