Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UBr2c-0007v8-AT for pgsql-sql@arkaria.postgresql.org; Sat, 02 Mar 2013 18:20:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UBr2a-00054f-JO for pgsql-sql@arkaria.postgresql.org; Sat, 02 Mar 2013 18:20:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UBr2Z-00053z-LR for pgsql-sql@postgresql.org; Sat, 02 Mar 2013 18:20:11 +0000 Received: from eastrmfepo203.cox.net ([68.230.241.218]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UBr2W-0008Qw-4G for pgsql-sql@postgresql.org; Sat, 02 Mar 2013 18:20:11 +0000 Received: from eastrmimpo305 ([68.230.241.237]) by eastrmfepo203.cox.net (InterMail vM.8.01.04.00 201-2260-137-20101110) with ESMTP id <20130302182006.ZJTD21186.eastrmfepo203.cox.net@eastrmimpo305> for ; Sat, 2 Mar 2013 13:20:06 -0500 Received: from slacker.ja10629.home ([68.100.172.111]) by eastrmimpo305 with cox id 6iL51l00N2QZvnG01iL5ch; Sat, 02 Mar 2013 13:20:06 -0500 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020209.513242D6.0026,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.0 cv=IelZrxWa c=1 sm=1 a=KkuxRCi8ThM9wmHDumrCpg==:17 a=z1TLwsU0kBEA:10 a=mYKVxQMGTtkA:10 a=PjkiJtDTOQ4A:10 a=ZcFhQy0-F_sA:10 a=kj9zAlcOel0A:10 a=P6M1L9rJAAAA:8 a=ShGMWBeL2rEA:10 a=gzE1qn6zAAAA:8 a=EWFYFy992cc2Zr_jUEgA:9 a=CjuIK1q_8ugA:10 a=z5boDq3hXNgA:10 a=KkuxRCi8ThM9wmHDumrCpg==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: from wcuddy by slacker.ja10629.home with local (Exim 4.72) (envelope-from ) id 1UBr2T-00042g-Hb for pgsql-sql@postgresql.org; Sat, 02 Mar 2013 13:20:05 -0500 Date: Sat, 2 Mar 2013 13:20:05 -0500 From: Wayne Cuddy To: pgsql-sql@postgresql.org Subject: Re: Need help revoking access WHERE state = 'deleted' Message-ID: <20130302182005.GG18317@slacker.ja10629.home> Mail-Followup-To: pgsql-sql@postgresql.org References: <20130228180201.GA10412@anubis.morrow.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130228180201.GA10412@anubis.morrow.me.uk> User-Agent: Mutt/1.4.2.3i X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On Thu, Feb 28, 2013 at 06:02:05PM +0000, Ben Morrow wrote: > Quoth mark@summersault.com (Mark Stosberg): > > > > We are working on a project to start storing some data as "soft deleted" > > (WHERE state = 'deleted') instead of hard-deleting it. > > > > To make sure that we never accidentally expose the deleted rows through > > the application, I had the idea to use a view and permissions for this > > purpose. > > > > I thought I could revoke SELECT access to the "entities" table, but then > > grant SELECT access to a view: > > > > CREATE VIEW entities_not_deleted AS SELECT * FROM entities WHERE state > > != 'deleted'; > > > > We could then find/replace in the code to replace references to the > > "entities" table with the "entities_not_deleted" table > > (If you wanted to you could instead rename the table, and use rules on > the view to transform DELETE to UPDATE SET state = 'deleted' and copy > across INSERT and UPDATE...) Ben, Sorry to barge in but I'm just curious... I understand this part "transform DELETE to UPDATE SET state = 'deleted'". Can you explain a little further what you mean by "copy across INSERT and UPDATE..."? > > > However, this isn't working, I "permission denied" when trying to use > > the view. (as the same user that has had their SELECT access removed to > > the underlying table.) > > Works for me. Have you made an explicit GRANT on the view? Make sure > you've read section 37.4 'Rules and Privileges' in the documentation, > since it explains the ways in which this sort of information hiding is > not ironclad. > > Ben Thanks, Wayne -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql