Ship

Security

What the starter enforces for you, and the rules your agent follows to keep it that way.

01Built in

AreaWhat it does
TenancyEvery workspace-owned row has organizationId; queries are scoped to the signed-in workspace, never to an ID from the browser
Sessionsproxy.ts redirects signed-out visitors; layouts check the session, team membership and admin role on the server
HeadersContent-Security-Policy, HSTS, X-Frame-Options DENY, nosniff, Referrer-Policy and Permissions-Policy in next.config.ts
Rate limitsrateLimit() in lib/rate-limit.ts, stored in Postgres so it holds across serverless instances
WebhooksStripe and Polar requests are rejected unless their signature verifies
SecretsServer files start with import "server-only"; env values are validated in lib/env.ts
Audit logTeam, role, API key, billing and admin actions are recorded
Supabasedb/enable-rls.sql turns on row-level security so the public API can't read tables

02Rules for new code

  • Get the workspace from requireWorkspace or workspaceFromParams and scope every query to ctx.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 with grantCredits or spendCredits.
  • Call audit() for anything security-relevant.
  • Add new third-party origins to the CSP in next.config.ts.