Policy for ADMIN/SUPER_ADMIN access returning empty results

Hi everyone,

I’m trying to create an RLS policy that only allows ADMIN and SUPER_ADMIN users (based on their app_metadata.role in the JWT) to view rows in my user_roles table.

Here’s what I currently have:

alter policy "Admins can view user_roles"
on "public"."user_roles"
for select
to authenticated
using (
((auth.jwt() -> 'app_metadata'::text) ->> 'role'::text) = ANY (ARRAY['ADMIN'::text, 'SUPER_ADMIN'::text])
);


The role field is definitely inside app_metadata in the JWT, but when I test this, even admin users get back an empty result set.

Am i missing something?
Was this page helpful?