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

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:
- Public Read Scope: Anonymous visitors can
SELECTonly rows whereis_published = true(orstatus = 'published'for blog articles). - Private Data Isolation:
contact_messages,keyword_targets,blog_revisions, and unpublished drafts are strictly blocked from anonymousSELECT. - Admin Write Guard: All
INSERT,UPDATE, andDELETEpolicies verifyis_admin(), aSECURITY DEFINERfunction with pinnedsearch_path = publiccheckingauth.uid()againstpublic.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.