S
Supabase8mo ago
Fr0$t

Multi-tenant authentication

Hello! I am currently planning a project, which would require multi-tenant logins. I'd like to be able to sign up users with the same emails but on different so called tenants, sort of like Firebase handles this. I am aware of the third party Firebase auth integration but as far as I know, it's only in a private alpha. Has anyone done something similar before? Does anyone have any ideas how this could work with the existing Supabase auth? Thanks for all the contributions!
3 Replies
craig
craig8mo ago
hey @Fr0$t - we have something like this. a multi-tenant system that supports external consultants who have access to several tenant accounts. it's largely modelled on the multi-tenant article by Ryan O'Neill (https://roughlywritten.substack.com/p/supabase-multi-tenancy-simple-and), but with consultant (and service) accounts added on top we searched around a fair amount and did not find any suitable library/extention that offered what we were looking for straight-out-of-box but the implementation was not onerously complicated make sure your RLS checks are rock-solid though 🍀
Fr0$t
Fr0$tOP8mo ago
Awesome! Thank you so much for sharing!
vick
vick8mo ago
I implement this with a many-to-many relation table that maps users to tenants, and making all of the RLS rules based on tenant ID. My mapping includes a permission level which is also accounted for in the RLS.

Did you find this page helpful?