From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Renato Cramer <renato(at)domsis(dot)com(dot)br> |
Cc: | "List Pgsql-General (E-mail)" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Access restrictions on rows depending on value of the a column |
Date: | 2004-08-12 16:30:10 |
Message-ID: | 20040812163010.GA5791@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Aug 12, 2004 at 09:54:25AM -0300, Renato Cramer wrote:
> There is data of several enterprises (ours clients) in a single database.
> All tables have a column on primary key what identify the enterprise called
> id_enterprise.
> My objective is restrict users access on rows depending on value of the
> column id_enterprise.
> That is, an user can access data only of his enterprise.
By "user" do you mean a PostgreSQL user, i.e., a user that can
connect directly to the database? Or do the users access the
database via an application? How is a user associated with a
particular id_enterprise value?
What kind of access to users require? Select only? Or also
insert, update, and delete?
> I don't want use where clause.
> There is some way of determine this in database?
For selects you could use views that join the tables against
a lookup table using id_enterprise and CURRENT_USER. Queries
against a view would get a subset of what's in a table, based
on who's doing the query. This assumes that the database user
can be mapped to one or more id_enterprise values via the
lookup table.
If you need to restrict inserts, updates, and deletes, then you
could use rules and/or triggers.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-08-12 16:46:13 | Re: Strange pg_hba.conf error (repost) |
Previous Message | Tom Lane | 2004-08-12 16:28:51 | Re: pl pgsql grammer file contains error |