Open joeyk16 opened 2 years ago
Hiyasirazgar can you see any issues with my setup?
Maybe your database user is a superuser? In this case RLS is bypassed. See postgres docs:
Superusers and roles with the BYPASSRLS attribute always bypass the row security system when accessing a table. Table owners normally bypass row security as well, though a table owner can choose to be subject to row security with ALTER TABLE ... FORCE ROW LEVEL SECURITY.
Hello, I've read all the docs about RLS and I still can't get it to work. I feel there's something I'm missing so any help would be great! If we can get it to work we start using it on a large-scale application.
Issue
Basically when I set the current tenant and run
User.all
I expect only the Users for the current tenant to be returned but I'm getting all users for all tenants. Can you see why it won't return only one User?Setup
I've created a new rails app so I can test how this works.
I have 2 models, an
Admin
and aUser
. Admin has many users and Admin is the tenant model.My setup is this:
I've run the
create_rls_functions.rb
migration and the below oneIt's created a user table that looks like this. I can see the policy below: