Ship
Security
What the starter enforces for you, and the rules your agent follows to keep it that way.
01Built in
| Area | What it does |
|---|---|
| Tenancy | Every workspace-owned row has organizationId; queries are scoped to the signed-in workspace, never to an ID from the browser |
| Sessions | proxy.ts redirects signed-out visitors; layouts check the session, team membership and admin role on the server |
| Headers | Content-Security-Policy, HSTS, X-Frame-Options DENY, nosniff, Referrer-Policy and Permissions-Policy in next.config.ts |
| Rate limits | rateLimit() in lib/rate-limit.ts, stored in Postgres so it holds across serverless instances |
| Webhooks | Stripe and Polar requests are rejected unless their signature verifies |
| Secrets | Server files start with import "server-only"; env values are validated in lib/env.ts |
| Audit log | Team, role, API key, billing and admin actions are recorded |
| Supabase | db/enable-rls.sql turns on row-level security so the public API can't read tables |
02Rules for new code
- Get the workspace from
requireWorkspaceorworkspaceFromParamsand scope every query toctx.organization.id. - Validate input at the boundary with zod, as the existing actions and routes do.
- Charge AI with
chargeAi()and refund on failure; change credits only withgrantCreditsorspendCredits. - Call
audit()for anything security-relevant. - Add new third-party origins to the CSP in
next.config.ts.