Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vebdl-0006nf-WC for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2013 02:17:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vebdl-0004IV-Ey for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2013 02:17:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vebdj-0004H8-VH for pgsql-hackers@postgresql.org; Fri, 08 Nov 2013 02:17:40 +0000 Received: from outmail149056.authsmtp.com ([62.13.149.56]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vebdg-000632-HJ for pgsql-hackers@postgresql.org; Fri, 08 Nov 2013 02:17:39 +0000 Received: from mail-c235.authsmtp.com (mail-c235.authsmtp.com [62.13.128.235]) by punt10.authsmtp.com (8.14.2/8.14.2) with ESMTP id rA82HTCn062733; Fri, 8 Nov 2013 02:17:29 GMT Received: from ayaki.localdomain (106-68-157-59.dyn.iinet.net.au [106.68.157.59]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id rA82HLud099631 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 8 Nov 2013 02:17:24 GMT Message-ID: <527C49B0.8080407@2ndquadrant.com> Date: Fri, 08 Nov 2013 10:17:20 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Dean Rasheed , Kohei KaiGai CC: Robert Haas , Tom Lane , Stephen Frost , Josh Berkus , "ktm@rice.edu" , Alexander Korotkov , Oleg Bartunov , Greg Smith , PgHacker Subject: Re: [v9.4] row level security References: <5220D832.7090104@agliodbs.com> <20130830192729.GO2706@tamriel.snowman.net> <16798.1377891794@sss.pgh.pa.us> <1398.1378305956@sss.pgh.pa.us> <1543.1378306249@sss.pgh.pa.us> <2620.1378308159@sss.pgh.pa.us> <52775604.9090306@2ndquadrant.com> <11101.1383575839@sss.pgh.pa.us> <52784DF9.9040205@2ndquadrant.com> <5279E3CA.7050400@2ndquadrant.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Server-Quench: ea10cc8a-481b-11e3-b802-002590a15da7 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadwMSJgVMAnde RXkJW1VXQF1zU2Jy YQhWIwRdZFRIVxtr VU9XR1tNFgBqBAMA SFxvWhsKC0ASeHd5 Y0VjEHVaWkR6OxMs Q04HRmVXeGNoaTIC UUENdB4GeANIYx9F aFV2VCIMZDFWYTQC El17DBAYFhZyEh9g CjITfBROdA4RGSF0 Qx0cEDFnBkAOWj8y Mw1O X-Authentic-SMTP: 61633235383639.1023:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 106.68.157.59/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 11/07/2013 06:11 PM, Dean Rasheed wrote: > I don't really get this part of the discussion. Why would you want to > make updatable SB views do any of that? I don't, especially. If we're going to use updatable SB views as the basis for RLS then we need the option to skip adding the qual for superuser. That might be done outside the SB code its self, by not invoking the SB view rewrite on the base rel when we see we're running as an RLS-exempt user. It's all about dealing with the re-plan problem really. > With SB views, however, you can have multiple SB views on top of the > same base table, each giving different users access to different > subsets of the data, and controlled by suitable GRANTs, and suitably > privileged users can be given direct access to the base table. This > also gives greater flexibility than the superuser/non-superuser > distinction being discussed here. That's a thought. Can we munge what the planner sees in pg_class instead? So when we see a ref to an RLS relation we transparently substitute the oid for a hidden SB view over the relation instead. For RLS exempt users we omit that substitution. Since the lookups and view subs are done in the rewrite phase it probably doesn't help us much, but it'd get rid of the need to play about with substituting a RTE_RELATION with an RTE_SUBQUERY dynamically during rewrite. > I don't think a view should ever show different data to different > users (unless it has been deliberately set up to do so) because that > would likely lead to confusion. Is there some other use-case that I'm > missing here? The main concern is pg_dump - it's important that dumps be able to take a complete copy without relying on hacks or bug-free user-written RLS quals. Highly privileged users should also be exempt from RLS so they don't invoke untrusted functions that're part of RLS quals written by lower-rights users. This isn't really "superuser" vs "not superuser. In fact we'll want a new right that controls whether RLS can be bypassed, and another that controls the ability to set RLS rights on tables. Both of those would be superuser only by default, but could be delegated. (Note: It's important that table owners _not_ get the right to set RLS on tables by default for security reasons. I'll explain in more detail later.) -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers