Ecosystem
Authentication and access
Sessions, CSRF protection, guards and scoped API tokens.
Install and configure auth
Configure the database accessor once, run the auth migrations and register root middleware.
Terminal
pnpm add ajo-kit-auth@0.6.1
pnpm exec kit migrate upAttach the request identity
Session middleware populates req.user. Explicit bearer credentials authenticate /api/* and take precedence over cookies there. Unsafe cookie-authenticated writes use CSRF protection.
src/wares.ts
import { configure, wares } from 'ajo-kit-auth'
import { db } from '/src/data'
configure(() => db())
export default [wares.session(), wares.csrf]Configure production secrets
Set APP_URL to the trusted public origin. APP_SECRET needs at least 32 random characters from your secret manager for verification links. Keep secrets in the host environment, outside source and build contexts. Production refuses missing, weak or sample secrets. Session and API token plaintext is not stored in the database.