Giter Club home page Giter Club logo

Comments (1)

fenos avatar fenos commented on May 28, 2024

@jahnavisana2812 Your use case seems more aligned with the use of RLS policies.

Potentially Supavisor could be injecting the tenant-id as a local configuration during connection, ex: SELECT set_config('supavisor.tenant_id', 'abcd') so that you can apply RLS policies using this value.

currently is not setting this option afaik, but you could use this same approach at the application level.

const client = sqlClient.connection()

// session mode
client.raw(`SELECT set_config('pooler.tenant_id', request.tenantId', false)` 

// tnx mode
const tnx = await client.transaction()
tnx.raw(`SELECT set_config('pooler.tenant_id', request.tenantId', true)` 

tnx.select('*').from('sometable')

then with the proper RLS it will isolate data for each tenant

ALTER TABLE my_table ENABLE ROW LEVEL SECURITY;

CREATE POLICY tenant_access ON my_table
FOR ALL
USING (tenant_id = current_setting('pooler.tenant_id'))
WITH CHECK (tenant_id = current_setting('pooler.tenant_id'));

Closing for now, as this can be done at the application level, but will re-open if we are thinking to introduce the local setting at connection time

from supavisor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.