Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is RLS_DATABASE_URL #4

Open
AndreiOvercode opened this issue Sep 11, 2023 · 8 comments
Open

What is RLS_DATABASE_URL #4

AndreiOvercode opened this issue Sep 11, 2023 · 8 comments

Comments

@AndreiOvercode
Copy link

AndreiOvercode commented Sep 11, 2023

What is RLS_DATABASE_URL and how do I get it? If I use
RLS_DATABASE_URL="postgres://rls_user
and
const users = await prisma .$extends( useSupabaseRowLevelSecurity({ claimsFn: () => ({ sub: '8a3611fb-204b-4cf1-8111-17269f9c7dce', }), }), ) .users.findMany();

I get an error Not authorised

@Jonatthu
Copy link

To connect to Postgres, you need to first createustom password and use that to a a role with a cuthenticate in your connection string. The claimsFn should be the decoded JWT obtained using Supabase Auth. For more guidance, please refer to the README.md file in this repository. Reading it a few times should make the process clear.

@louishugens
Copy link

Hi @Jonatthu,

It is still not clear to me how to get this extension in my project. Do i need to clone the repo inside my project? Thank you in advance.

@Jonatthu
Copy link

Jonatthu commented Oct 2, 2023

Just copy the extension itself not the entire repo, then you can use it on prisma. Make sure you pass the claims on every single request

@louishugens
Copy link

thanks a lot @Jonatthu

@louishugens
Copy link

@Jonatthu would you accept to give a consultation on implementing this? I stumble upon a bunch of typescript errors. I need to move forward. Please let me know.

@Jonatthu
Copy link

Jonatthu commented Oct 2, 2023

Can you screenshot?

@louishugens
Copy link

louishugens commented Oct 2, 2023

here is the ts error
Argument of type '(client: PrismaClient) => DynamicClientExtensionThis<Prisma.TypeMap<Args_2 & { result: {}; model: {}; query: {}; client: {}; }>, Prisma.TypeMapCb, { result: {}; model: {}; query: {}; client: {}; }>' is not assignable to parameter of type '{ name?: string | undefined; query?: DynamicQueryExtensionArgs<{ $queryRaw?: unknown; $executeRaw?: unknown; $queryRawUnsafe?: unknown; $executeRawUnsafe?: unknown; profile?: unknown; appointment?: unknown; users?: unknown; skill?: unknown; category?: unknown; subCategory?: unknown; subSubCategory?: unknown; availab...'. Type '(client: PrismaClient) => DynamicClientExtensionThis<Prisma.TypeMap<Args_2 & { result: {}; model: {}; query: {}; client: {}; }>, Prisma.TypeMapCb, { result: {}; model: {}; query: {}; client: {}; }>' is not assignable to type '(client: DynamicClientExtensionThis<TypeMap<Args_2 & DefaultArgs>, TypeMapCb, DefaultArgs>) => { ...; }'. Types of parameters 'client' and 'client' are incompatible. Type 'DynamicClientExtensionThis<TypeMap<Args_2 & DefaultArgs>, TypeMapCb, DefaultArgs>' is missing the following properties from type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>': $on, $use

here the screenshot:
image

I also ha this when passing the extention to the prisma client:
React Hook "useSupabaseRowLevelSecurity" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.

@nbaasmf
Copy link

nbaasmf commented Oct 26, 2023

I also get that TS error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants