I have enabled RLS on a db table and i have not cr...
# help
b
I have enabled RLS on a db table and i have not created any policies, yet i am still able to access the rows in the table. Essentially i've enabled RLS and it seems to not be locking down my table. Anyone know what could be going wrong?
g
How are you accessing the table? The table UI, SQL editor and accesses with service_role key will bypass it.
b
@User I'm accessing it through the supabase client in a nextjs application
g
With anon key?
b
Yes
g
If you want maybe show some code. Sort of opposite the usual RLS problems around here...
b
Lol i noticed
Ok actually I misspoke. I'm using the prisma client. I'm using the supabase client for logging in and out. But here is an example
Copy code
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
  const prisma = new PrismaClient();

  const animals = await prisma.animals.findMany();
  console.log("getting animals", animals);

  return {
    props: { animals: JSON.parse(JSON.stringify(animals)) },
  };
};
g
I don't know much about Prisma but I believe it is logged in thru postgres user so would bypass RLS.
b
I'll get back to googling and let you know if I find anything. Assuming you're interested in the answer. I appreciate the response though
Yeah good call on prisma.
Copy code
Prisma with Supabase RLS policies
For a recent task I had to set up Prisma to take into account RLS (Row Level Security) policies set up in Supabase. This, as you know, is difficult to achieve as by default Prisma opens a direct connection to the database, and that too with the postgres user that has permissions to bypass every RLS policy.
@User from what I'm seeing I'm not thinking that using Prisma is not worth it at this point. What do you use with supabase? just the supabase client?
Also curious how you handle DB migrations
g
I just use client, but I also am just me and a simple app with a simple database. I've not worried about migrations yet. Supabase is working on some minimal migration tools. I also see lots of web info on options. https://github.com/supabase/cli/tree/main/examples/tour https://supabase.com/blog/2021/03/31/supabase-cli
b
thanks!