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_rolekey - Files that should never be public, like
/.envand/.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
- Supabase: in RLS policies or security-definer functions that check a role stored in a table users can't edit (or in a custom JWT claim set by the server), not in
user_metadata. - Firebase: in Security Rules using custom claims (
request.auth.token.admin == true) set with the Admin SDK. - Your own API / server actions: check the session and role on every request, inside the handler.
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.
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.
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.