Re: Restricting access to rows? - Mailing list pgsql-general

From Kenneth Downs
Subject Re: Restricting access to rows?
Date
Msg-id 4476FEEC.9030500@secdat.com
Whole thread Raw
In response to Re: Restricting access to rows?  ("Josue E. Maldonado" <josue@lamundial.hn>)
List pgsql-general
Josue E. Maldonado wrote:

> Benjamin Smith wrote:
>
>> How can I set up a user so that Bob can update his records, without
>> letting Bob update Jane's records? Is it possible, say with a view or
>> some other intermediate data type?
>
>
> I've done something similar using a separate control table where I set
> what accounts an user can "see", then I wrote a psql that returns just
> the rows for that especific user, it could also be done with pure SQL
> joins tough.
>
>
>
You can put in a some triggers that do a few things, and I think a rule
on SELECT will round it off.

on Insert: populate a column with CURRENT_USER
on Update and Delete: refuse unless CURRENT_USER matches the column
on SELECT rules, apply a filter that column = CURRENT_USER

You also may put in an override for all three that if the CURRENT_USER
is in some particular group these filters will not apply.  One level
might be just for selects, a higher level for updates/deletes.

Or you can do the reverse, and say that these filters only apply if the
user is in a certain group.

Attachment

pgsql-general by date:

Previous
From: "Florian G. Pflug"
Date:
Subject: Re: LDAP authentication
Next
From: "A. Kretschmer"
Date:
Subject: Re: Incomplete dump?