Redwood and Supabase Auth Example

I’d really welcome that @kiwicopple.

I should have started with the what and why and not the how.

  • Have a way to assign “app/business” user roles to users
  • That that made available in the RW’s currentUser’s user_metadata (either from JWT direct or enriched with info and set) so that the web side can determine if the user “hasRole()” to gain access to protected areas of the app

If that is the case then you can add it either to auth.users.raw_app_metadata or auth.users.raw_user_metadata - these will both be encoded into the JWT when the user session is created

  • when querying/updated data via Prisma, have some way of identifying the user so that RLS and policies can still be enforced at the PG level

Some points to know:

  • Prisma can query across schemas, so it’s not that easy to join the public and auth schemas in Supabase. You have to compose the SQL yourself via a rawQuery

Maybe we adapt the Blog w/ RBAC Tutorial that currently uses Netlify but a fork that uses Supabase PG and Auth instead? I could even add storage for photos next :wink:

The Uses Netlify Identity Trigger Serverless function calls to assign roles when signing up feature could also showcase some upcoming SB features when a new user is created (hint).

1 Like