If a table still returns rows with the anon key, the policy is not doing what you think. Check these three things in order.
1. RLS is not enabled
A policy does nothing if RLS is off.
alter table public.orders enable row level security;
2. The policy uses using (true)
This is the most common AI-generated policy. It allows every row to everyone.
-- wrong
create policy "read" on public.orders for select using (true);
-- right
create policy "own orders" on public.orders
for select using (auth.uid() = user_id);
3. The policy is on the wrong command
select does not cover insert, update, or delete. Add the commands you actually need.
create policy "insert own order" on public.orders
for insert with check (auth.uid() = user_id);
Verify, do not assume
Run a request with only the anon key:
curl "$SUPABASE_URL/rest/v1/orders?select=*&limit=1" -H "apikey: $ANON_KEY" -H "Authorization: Bearer $ANON_KEY"
A correct policy returns 401/403 or an empty list. A broken policy returns someone else's rows.