Re: RLS without leakproof restrictions?

From: "Martin L(dot) Buchanan" <martinlbuchanan(at)gmail(dot)com>
To: Tom Dunstan <pgsql(at)tomd(dot)cc>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: RLS without leakproof restrictions?
Date: 2023-02-22 02:41:49
Message-ID: CAPfd9MnGK9LWpRTy4NQ0U5U+eQ-et5JjPjKcaKkZcyJv_HSp7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> On Tue, Feb 21, 2023 at 5:57 PM Tom Dunstan <pgsql(at)tomd(dot)cc> wrote:

> Hi all
>
> 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.
>
> Alternatively, are the concerns about changed plans unfounded? For example
> we don't use many expression indexes or exotic types, it's mostly btrees on
> text and ints. We do use tsearch a certain amount, but constructing
> tsvectors and tsqueries manually rather than through stemmers etc.
>
> Thanks
>
> Tom
>

<<

OK, I don't have that PG >> look quite right.

Anyway, Tom if it is feasible to put each tenant into its own database on
the same server instance, that is what I recommend. Even with row level
security, a tenant ID on each row in each table and each view and each
function or procedure that deals with tenant-specific data, is a headache
that can also complicate queries and query plans.

(Am speaking for myself as a PG developer for the last 2.5 years, not for
my employer.)

Sincerely,

Martin L Buchanan
Laramie, WY, USA

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Dunstan 2023-02-22 03:45:55 Re: RLS without leakproof restrictions?
Previous Message Cathy Xie 2023-02-22 01:18:12 Re: Debugging postgres on Windows - could not open directory "/lib"