THUSHAN

Architecture & Security

Building a Secure Online Admin CMS with Supabase PostgreSQL & Row-Level Security

Enforcing public read boundaries and admin-only mutations without maintaining a custom backend server

By Thushan Rathnayaka · Published 2026-11-25 · Updated 2026-11-25

Supabase RLS CMS architecture overview

Summary: How our portfolio CMS combines Supabase Auth, a SECURITY DEFINER is_admin() helper, Row-Level Security policies, and Storage buckets to support live online updates safely.

Separating UI Releases from Content Publishing

Rebuilding and redeploying an entire frontend bundle for every project edit or blog update slows down publishing and wastes CI/CD minutes. Using Supabase PostgreSQL as the live source of truth lets the Admin Panel publish updates immediately while Cloudflare Pages Functions dynamically reflect changes in HTML metadata, structured data, and sitemap.xml.

Row-Level Security Pattern

Every content table enforces PostgreSQL RLS:

  1. Public Read Scope: Anonymous visitors can SELECT only rows where is_published = true (or status = 'published' for blog articles).
  2. Private Data Isolation: contact_messages, keyword_targets, blog_revisions, and unpublished drafts are strictly blocked from anonymous SELECT.
  3. Admin Write Guard: All INSERT, UPDATE, and DELETE policies verify is_admin(), a SECURITY DEFINER function with pinned search_path = public checking auth.uid() against public.profiles.

Automated Verification in CI

Our route smoke tests explicitly send an unauthenticated POST with the public anon key against projects and verify Supabase returns 401 or 403. Never rely on UI hiding alone for security.

Topics: Supabase · PostgreSQL · Row-Level Security · CMS · Security

Supporting References & Sources