pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Dunstan <pgsql@tomd.cc>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: RLS without leakproof restrictions?
Date: Tue, 21 Feb 2023 22:46:05 -0500
Message-ID: <4136571.1677037565@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPPfruzMB1RQ0LMjHQe=MT1KhDHzaT_gduaMa20dbxC8f6B7og@mail.gmail.com>
References: <CAPPfruzMB1RQ0LMjHQe=MT1KhDHzaT_gduaMa20dbxC8f6B7og@mail.gmail.com>

Tom Dunstan <pgsql@tomd.cc> writes:
> I'm currently researching different strategies for retrofitting some
> multi-tenant functionality into our existing Postgres-backed application.
> One of the options is using RLS policies to do row filtering. This is quite
> attractive as I dread the maintenance and auditing burden of adding
> filtering clauses to the majority of our queries. I'm somewhat concerned
> though about getting unexpected query plans based on the planner avoiding
> non-leakproof functions until row filtering has occurred - warning about
> this seems common in articles on RLS.

> Our application is the only "user" of the database, and we do not pass
> database errors through to the user interface, so for our case leakproof
> plans are overkill - we'd just like the implicit filtering clauses added
> based on some session GUCs that we set.

> Is there any way to get what we're looking for here? I don't see anything
> documented on CREATE POLICY, ALTER TABLE or any GUCs.

If you're happy allowing the application to decide if the filters will
be enforced, maybe just create some views embodying those filters, and
query those views when you want restrictions?

> Alternatively, are the concerns about changed plans unfounded?

Hard to tell without experimentation.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <4136571.1677037565@sss.pgh.pa.us>
Permalink:  ../4136571.1677037565@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4136571.1677037565@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql@tomd.cc
  Subject: Re: RLS without leakproof restrictions?
  In-Reply-To: <4136571.1677037565@sss.pgh.pa.us>
  References: <CAPPfruzMB1RQ0LMjHQe=MT1KhDHzaT_gduaMa20dbxC8f6B7og@mail.gmail.com> <4136571.1677037565@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox