Auth & Permissions
Middleware chain:
middleware.jsuseswithStableIdandwithAuthfrommiddlewares/*- Excludes API, static assets, auth-related public routes via
config.matcher
Tokens & identity:
lib/getTokens.jsparses cookies/headers into{ token, rootToken, idToken, companyId, userCompanyId, stableId }- GraphQL context requires tokens; in Postgres mode,
authMiddlewarevalidatesidToken/companyId, sets Supabase client and decoded JWT
Roles & permissions:
- Roles:
ADMIN,OPERATOR,DRIVER,PARTNER(see enums in Prisma and schema) - Server-side checks in services/resolvers; UI gates via
permission-gate/feature-gate