Clerk or a custom OIDC provider on Supabase: 3 RLS traps when your app trusts another issuer

Supabase now has a Custom OIDC option under Authentication > Third-Party Auth, next to Clerk, Auth0, WorkOS, Firebase and Cognito. Supabase's changelog: "Supabase then accepts JWTs signed by that issuer."

Your RLS policies were written for Supabase Auth tokens. Tokens from another issuer carry different claims, and three small gaps show up again and again. All quotes below are from Supabase's custom OIDC guide unless noted.

Trap 1: no role claim, so every signed-in user is anon

"Without a role claim, requests run as the anon role."

Your app shows a logged-in user, but every query acts as if nobody is signed in: empty lists or 42501 permission denied. The tempting fix is to add to anon rules until data appears. That makes the data public.

Fix: issue tokens with role: "authenticated". For Clerk, Supabase's Clerk guide says, if you can't use Clerk's Connect with Supabase page: "Add the role claim to Clerk session tokens by customizing them." Then delete any anon rules you added while debugging. More: 42501 permission denied.

Trap 2: auth.uid() breaks on non-UUID user IDs

"auth.uid() casts sub to uuid, so it fails if your provider issues subjects that are not UUIDs." Clerk user IDs look like user_2abc....

When those policies start failing, an AI assistant will often patch them with using (true). RLS stays on, and every signed-in user can read every row.

Fix: keep the provider's ID in a text column and compare it to the claim:

create policy "Users can read their own rows"
  on table_name for select to authenticated
  using (user_id = (select auth.jwt()->>'sub'));

Trap 3: two issuers, colliding user IDs

"Your project trusts every issuer you add, and sub values from different issuers can collide." If you run Supabase Auth and Clerk, or two OIDC providers, a policy that only checks sub can match a user from the wrong issuer.

Fix: add one restrictive policy per table that checks iss:

create policy "Restrict access to trusted issuers"
  on table_name as restrictive to authenticated
  using (
    (auth.jwt()->>'iss' = 'https://<project-ref>.supabase.co/auth/v1')
    or (auth.jwt()->>'iss' = 'https://login.example.com')
  );

Supabase: "make sure you don't omit the as restrictive clause." Without it the policy is permissive and widens access instead of narrowing it.

Check it in one minute

  1. In the SQL editor:
    select tablename, policyname, permissive, roles, qual
    from pg_policies where schemaname = 'public'
    order by tablename;
    Look for a qual of true, auth.uid() on tables whose users come from your provider, anon in roles on tables that need a login, and (with more than one issuer) any table without a RESTRICTIVE row that checks iss.
  2. Sign in as two different users and confirm each sees only their own rows: the second-user test.

Before you launch

The free Ship-Ready quick scan runs offline on your code and flags leaked keys, RLS turned off, using (true) policies and edge functions with verify_jwt = false and no caller check. It does not check issuer (iss) policies yet, so run the query above. The Crew (59-check scan, $39) adds more checks and a two-user test template.

Related: Login is not access control · 42501 permission denied · Edge function 401 Invalid JWT after the new keys