Firestore has policy documents which
describe access rules for documents inside a collection. You can specify a rule for read and write. You can use JavaScript inside a rule. The docs:
https://firebase.google.com/docs/firestore/security/get-started
The advantage of such a system in Supabase is users will not have to spend time learning about RLS and SQL policies (unless they want to). The underlying RLS and SQL policies would be abstracted away and handled by Supabase. It also would help Firebase devs transitioning to Supabase (like me) as they can "convert" their policies over. You would write SQL-like code and Supabase would translate it into actual SQL and RLS.
Example Supabase policy document:
{
match /tables/public/user_profiles {
match /{id=**}/ {
allow read;
allow write: if "id" = auth.uid();
}
}
}
Could be translated into (my SQL isn't very good):
sql
ALTER TABLE user_profiles
ENABLE ROW LEVEL SECURITY;
CREATE POLICY "read"
ON user_profiles FOR SELECT USING (
true
);
CREATE POLICY "write"
ON users FOR UPDATE USING (
auth.uid() = id
);