https://supabase.com/ logo
Hey ,can we create a policy for a table in which u...
# help
v
Hey ,can we create a policy for a table in which users in that table can only access it.
n
Hello @vMInvincible! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
v
For example if a person login’s in with an email a policy should check if the person is on the table is yes then he/she can access it
g
You you can, but you will have to use a security definer function to get the user_ids and then do an in on that for auth.uid() (or some similar approach). You will not be able to access the users in the table to get the policy to work if the policy is on the table directly, hence the sd function. Edit I guess just a sql user id exists in the sd function would work.
v
Can you please give me an example
g
This link https://supabase.com/docs/guides/auth/row-level-security#policies-with-security-definer-functionshows shows setting up a security definer function for use in a policy. There are other helpful examples of policy on that page that might be close to what you want to do. I would have to google for an example or write code to provide your exact example.
v
Okay thanks , i will try this
Hey ! Can we add specific email_id list who can access the table
I just want to restrict access on a table ! Using whatever means possible
g
RLS is just an extra where statement. You can pretty much use any sql you want on the table or using other tables (like an approved email table), look at the domain of an email, etc. The only real limit is keeping it as simple as possible for performance as the sql could be run against every item in the table depending on your filters and what you are doing.
v
Okay ! 👍🏻
3 Views