Home / Guides / Hiding the admin button isn't access control: protect admin routes properly

Hiding the admin button isn't access control: protect admin routes properly

In AI-built apps, admin pages are often protected only in the UI. How to enforce admin access where the data lives.

Check your live site

Run the free ShipLatch scan on your own site without leaving this page.

Uses 1 of your 3 free scans today; a site scanned in the last 24 hours answers from that scan. Passive and read-only: we only look at what any browser can see. Only check sites you own or may test.

What the free scan checks

  • Leaked keys in your live JavaScript (AI, payment and cloud keys), including a Supabase service_role key
  • Files that should never be public, like /.env and /.git
  • Supabase and Firebase secrets in the browser: an sb_secret_ key, a Supabase access token or a Firebase service-account file
  • HTTPS and security headers (CSP, HSTS, clickjacking protection)

It only reads what any visitor's browser can see. It doesn't log in, read your tables or check App Check.

A common AI-generated pattern: if (user.isAdmin) showAdminButton(). The page or button disappears, but the data and actions behind it are still reachable by anyone who calls the API directly from DevTools.

Where the check must live

Example: Supabase admin-only table

create table public.admins (user_id uuid primary key references auth.users);
alter table public.admins enable row level security;  -- no policies: clients can't read or edit it

create policy "admins read all orders" on public.orders for select to authenticated
  using (exists (select 1 from public.admins a where a.user_id = (select auth.uid())));

Test it

Log in as a normal user, open DevTools → Network, copy an admin request and replay it (or open /admin directly). It should fail with 401/403 or return no rows.

Copy-paste into your AI builder
Find every admin-only page, action and query in this app. Enforce admin access server-side (RLS policies or server route checks using a role users cannot modify), not just by hiding UI. Then tell me how to test it as a non-admin user.

Related: RLS policy examples · Pre-launch checklist

Scan your app free

Paste your URL. ShipLatch checks for leaked keys, exposed /.env and /.git, and flags Supabase/Firebase so you know what to lock down. The free scan finds the issues; the $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.

Scan free at shiplatch.com → See the Fix Pack · $9 playbook

Want the whole pre-launch process in one place? See what's inside App Security for Vibe Coders, our $9 PDF playbook, or go straight to checkout.

More guides