Re: RLS Design - Mailing list pgsql-hackers

From Robert Haas
Subject Re: RLS Design
Date
Msg-id CA+TgmoYu1YOGyodfNscJBw5NrLHpE-xmJ=Urfjj+7vMyy4R5dw@mail.gmail.com
Whole thread Raw
In response to RLS Design  (Stephen Frost <sfrost@snowman.net>)
Responses Re: RLS Design  (Stephen Frost <sfrost@snowman.net>)
Re: RLS Design  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
On Tue, Jun 24, 2014 at 8:49 PM, Stephen Frost <sfrost@snowman.net> wrote:
> Let's try to outline what this would look like then.
>
> Taking your approach, we'd have:
>
> CREATE POLICY p1;
> CREATE POLICY p2;
>
> ALTER TABLE t1 SET POLICY p1 TO t1_p1_quals;
> ALTER TABLE t1 SET POLICY p2 TO t1_p2_quals;

This seems like a very nice, flexible framework.

> GRANT SELECT ON TABLE t1 TO role1 USING p1;
> GRANT SELECT ON TABLE t1 TO role2 USING p2;

Instead of doing it this way, we could instead do:

ALTER ROLE role1 ADD POLICY p1;
ALTER ROLE role2 ADD POLICY p2;

We could possibly allow multiple policies to be set for the same user,
but given an error (or OR the quals together) if there are conflicting
policies for the same table.  A user with no policies would see
everything to which they've been granted access.

To support different policies on different operations, you could have
something like:

ALTER TABLE t1 SET POLICY p1 ON INSERT TO t1_p1_quals;

Without the ON clause, it would establish the given policy for all operations.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: idle_in_transaction_timeout
Next
From: Tom Lane
Date:
Subject: Re: makeAndExpr(), etc. confined to gram.y?