AnotherWrapper includes several security layers out of the box. Here’s what’s built in and what you should add before launch.
Security Layers
Auth & Session Protection
Auth & Session Protection
The repo uses centralized helpers in For server components and pages, use Always use these helpers instead of rolling your own auth checks. They handle the edge cases for you.
lib/auth/server.ts for all server-side auth checks.For API routes, use requireApiUser():app/api/protected/route.ts
requireUser():app/protected/page.tsx
Database Ownership Checks
Database Ownership Checks
The default model enforces ownership through authenticated server helpers and user-scoped queries — not database-level RLS policies. This keeps the starter portable across PostgreSQL hosts.The practical rules:This pattern prevents one user from reading or mutating another user’s records.
- Fetch the current user on the server
- Scope reads and writes by
user.id - Keep that logic in
lib/db/*instead of scattering it across UI code
Rate Limiting (Recommended)
Rate Limiting (Recommended)
Rate limiting isn’t enabled by default, but it’s straightforward to add. Target expensive AI routes, upload routes, and auth endpoints first.Here’s an example middleware shape using Upstash:
middleware.ts
AI Cost Protection
AI Cost Protection
AI services can get expensive fast. Protect yourself on two levels:Provider-level: Set budget alerts and hard spending limits in every AI provider dashboard you enable (OpenAI, Anthropic, Google, etc.).Application-level: The credit system acts as a usage meter. Users must have sufficient credits for paid AI features, and credits are consumed through transactional database updates to prevent race conditions.
Email Security
Email Security
Magic link and password-reset emails go through your configured provider (Resend, Loops, or Brevo), not through a bundled SMTP path.Before launch:
- Verify your sender domain
- Monitor bounces and suppressions
- Rate limit auth email endpoints if abuse becomes a concern
- Test magic link and reset-password delivery

