Sign-in and two-factor
Admins sign in with Supabase Auth. In Settings > Security an admin can turn on an authenticator app. Two-factor is enforced in the database, not only in the interface: the SQL function mfa_satisfied() returns true only when the session is at assurance level 2 or the user has no verified factor, and is_admin() and is_owner() both require it. A password alone therefore cannot read admin data once an account has two-factor on. Accounts without a verified factor sign in with a password only.
Roles
- Owner: everything.
- Editor: day-to-day work such as writing posts and pages, the inbox, chat and media.
Owner-only in the code: Settings (design, chat, branding), team management, the activity log, backup download, importing file posts, deleting pages, and sending newsletters (including test sends). An editor who opens an owner-only page is sent back to /admin; owner-only actions refuse editors.
New admins are added by creating the user in Supabase > Authentication and inserting a row into admin_users. Nobody becomes an admin by signing up.
Row Level Security
RLS is on for every table. Visitors can read only published posts and public settings, and only the post columns the site renders. Everything else needs a user in admin_users. Public forms, tracking and chat write through the service-role key on the server, after validation. That key never reaches the browser.
Every admin page and server action re-checks the session and role on the server. The proxy (src/proxy.ts) only refreshes the session and redirects signed-out visitors.
Setup wizard
/setup creates the first owner only when no admin exists, SETUP_TOKEN is set (24+ characters), the submitted token matches (constant-time comparison) and the rate limit allows it. Once an owner exists, visitors who are not signed-in admins see only "Setup is complete".
Headers and content
Security headers are set in next.config.ts: Content-Security-Policy (no framing, no plugins, scripts and connections limited to this site, Supabase and Turnstile), HSTS, X-Content-Type-Options, X-Frame-Options: DENY, Referrer-Policy and Permissions-Policy. Admin pages are noindex and no-store. MDX written in the CMS cannot run JavaScript. Custom CSS cannot contain <.
Rate limits
In-memory limits per visitor on public endpoints: contact 5 per 10 minutes, subscribe 8, bookings 6, event registration 8, resource download 5, page-view tracking 30 per minute, booking and ticket management 20 per 10 minutes, account actions 8 per 15 minutes, setup 5 per 15 minutes. Each serverless instance keeps its own counters, so they are a first line of defence; the chat and tracking endpoints also have database-backed caps (0003_hardening.sql).
Backup
Settings > Backup (owner only) downloads a JSON file of the CMS tables. Image files stay in Supabase Storage. The file contains subscriber emails, so store it privately. Supabase's free plan has no automatic backups, so download one regularly.
Reporting
Keep SUPABASE_SERVICE_ROLE_KEY, CRON_SECRET and SETUP_TOKEN out of Git and logs. Rotate the service-role key in Supabase if it ever leaks.