X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A668011F60AF for ; Tue, 25 Apr 2006 06:40:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 68611-02 for ; Tue, 25 Apr 2006 06:40:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by postgresql.org (Postfix) with ESMTP id 361CC11F6095 for ; Tue, 25 Apr 2006 06:40:15 -0300 (ADT) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by ptb-relay01.plus.net with esmtp (Exim) id 1FYK1n-0006eQ-5z; Tue, 25 Apr 2006 10:40:15 +0100 Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 9351073660; Tue, 25 Apr 2006 10:43:42 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 6CF5715EA7; Tue, 25 Apr 2006 10:40:09 +0100 (BST) Message-ID: <444DEE78.7020703@archonet.com> Date: Tue, 25 Apr 2006 10:40:08 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Friends Cc: pgsql-performance@postgresql.org Subject: Re: security for row level but not based on Database user's References: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> In-Reply-To: <1145615328.300612.56380@e56g2000cwe.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/542 X-Sequence-Number: 18626 Friends wrote: > Hi > > I need to set security for row level but not based on Database user's > login. It should be based on the user table login. For the particular > user I need to allow only the particular records to access insert, > update delete and select. Well, the data access stuff is all manageable via views, which is the standard way to do this. You don't say which version of PostgreSQL you are using, but I'd be tempted just to switch to a different user after connecting and use the session_user system function to control what is visible in the view. For example: CREATE VIEW my_contacts AS SELECT * FROM contacts WHERE owner = session_user; If that's not practical then you'll need to write some functions to simulate your own session_user (say application_user()). This is easiest to write in plperl/pltcl or some other interpreted language - check the list archvies for plenty of discussion. -- Richard Huxton Archonet Ltd