Re: Design question: Should "postgres" own all the db objects?

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Andreas *EXTERN*" <maps(dot)on(at)gmx(dot)net>, "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Design question: Should "postgres" own all the db objects?
Date: 2009-07-13 08:16:12
Message-ID: D960CB61B694CF459DCFB4B0128514C203937E1C@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andreas wrote:
> who should own the db objects?
> I once read one should not let postgres or any other superuser own the
> tables and what not.
> Instead one should better create a separate user role with little
> privileges to be the owner.
> I'm not quite sure why this was abvised. Maybe like not using root for
> everyday work.
>
> What is commonly regarded as good design in this issue?

It is good practice to assign as few privileges as possible to
an application user.

As a consequence, it is a good idea not to have the application
user own any database objects (because the owner can drop or
modify them).

The same principle can be applied to the owner of the database objects:
That user need not have more privileges than necessary for creating
and maintaining database objects.

Your point of not doing everyday work as root is one good reason.
Another is functions that are defined as SECURITY DEFINER.
These functions will run with the permissions of the owner, no
matter who calls them. Consequently the owner of such a function
should also not have more privileges than necessary, so that
if the function contains a security hole, the damage will be
limited.

We routinely use a setup with two or more users:
One "admin" user owns the database objects. Only our DBAs
have the password of this user, and no application is allowed
to connect with this user.
Then there are one or more "normal" users who are granted the
necessary rights on the objects. These users are used by the
application to connect to the database.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2009-07-13 08:17:15 Re: Re: [BUGS] BUG #4916: wish: more statistical functions (median, percentiles etc)
Previous Message Mel Flynn 2009-07-13 08:01:51 uuid_hash declaration