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
orauth.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
andauth
schemas in Supabase. You have to compose the SQL yourself via arawQuery
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
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).