Designing Postgres Security Model

From: dipti shah <shahdipti1980(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Designing Postgres Security Model
Date: 2010-03-28 09:53:48
Message-ID: d5b05a951003280253w65de0293p32409abdce079004@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Hi,

Could anyone please suggest me how to deal with my following requirements.
So far, I have done following to meet my requirements:
*
I want users to use only stored procedures to create, alter, delete tables
in mydb schema*. ==> For this, I have *revoked all permissions from
mydb *schema,
and stored procedures are defined with SECURITY DEFINER in postgres user
context. I have given execute permission to set of users on these stored
procedures to achieve my goal.

*I want only privileged users to create table with foreign key
references.*==> This can be achieved using SET ROLE current user
before executing create
command but *Postgresql doesn't allow running SET ROLE in SECURITY DEFINER
function* *context* so I have created a my_sudo function which gets invoked
from my stored procedure. This sudo function creates a temporary SECURITY
DEFINER function and changes *owner to the current user before executing
create table command.
*
Now, as sudo function runs actual create command as current user context and
he/she does not have permission on mydb schema(as revoked all permission to
meet first requirement), I have to grant the ALL permissions on mydb schema
to current user temporary and then restore his/her actual privileges back to
make sure that users actual permission doesn't change.

*Problem:* Could anyone tell me how to get the schema permissions list for
current user and restore it back once store procedure execution completed.

Please feel free to let me know if you have any questions.

Thanks a lot,
Dipti

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2010-03-28 11:22:27 Re: Why index occupy less amount of space than the table with same structure.
Previous Message Tadipathri Raghu 2010-03-28 08:05:48 Why index occupy less amount of space than the table with same structure.

Browse pgsql-novice by date

  From Date Subject
Next Message L. Loewe 2010-03-29 00:19:04 slow plan on join when adding where clause
Previous Message Vitali Xevet 2010-03-28 04:30:25 Clustering/fail-over solution