supabase / wrappers

Postgres Foreign Data Wrapper development framework in Rust.
http://fdw.dev
Apache License 2.0
562 stars 55 forks source link

Cannot query Stripe FDW using client sdk #339

Closed julian-hecker closed 1 month ago

julian-hecker commented 2 months ago

Bug report

Describe the bug

Cannot query data from the Stripe FDW using client sdk. I have tried several different ways but have not managed to do this successfully. Not even using the service role key.

To Reproduce

  1. Go to the Supabase Dashboard Settings > Database > Wrappers and set up Stripe FDW. Create the foreign tables in the public schema.
  2. Attempt to query the tables from the client sdk, any key - anon or service_role
    const { data } = await supabase.from('public.stripe_products').select().throwOnError();
  3. Produces the following error message:
    permission denied for schema vault

I have also reproduced the issue this way:

  1. Go to Supabase Dashboard Settings > Database > Wrappers and setup Stripe FDW, but this time create the foreign tables in a private schema named stripe.
  2. Create a view in the public schema which displays the data from the foreign table.
    create or replace view public.products as select * from stripe.products;
  3. Attempt to query the view from the client sdk, use any key: anon or service_role
    const { data } = await supabase.from('public.products').select().throwOnError();
  4. Same error message is produced
    permission denied for schema vault

Expected behavior

I expected to be able to query the data that is visible in the public schema. I am trying to use stripe to store product data which should be visible to customers.

Related Issues

burmecia commented 1 month ago

The foreign table does not provide Row Level Security, so it is not advised to expose them via API (client sdk) access. The Wrappers Docs explained this in details and provided security definer function as an alternative solution.