User Tools

Site Tools


schema_0_9_10_grants

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
schema_0_9_10_grants [2008/11/08 17:16] danielschema_0_9_10_grants [2008/11/08 18:02] (current) daniel
Line 1: Line 1:
 ====== Schema access rights ====== ====== Schema access rights ======
-The policy for dealing with access rights is left to the administrator and exercised using SQL commands, as is the creation of database users.\\ +Access rights management is left to the administrator by way of self-written SQL commands, as is the creation of database users.\\ 
 This page gives some basic guidelines on how to manage a database with multiple users in a typical scenario: This page gives some basic guidelines on how to manage a database with multiple users in a typical scenario:
   * One dedicated database user is the owner of the database and all its objects. This is the user that runs the initial creation script.   * One dedicated database user is the owner of the database and all its objects. This is the user that runs the initial creation script.
   * One or several roles (=groups) are created with //CREATE ROLE// commands.   * One or several roles (=groups) are created with //CREATE ROLE// commands.
-  * Access rights are affected to each role for each database object (tables, functions, sequences, views) with //GRANT SELECT,INSERT,...// commands.+  * Access rights are assigned to each role for each database object (tables, functions, sequences, views) with //GRANT SELECT,INSERT,...// commands.
   * Per-user account are created with //CREATE USER// commands.   * Per-user account are created with //CREATE USER// commands.
   * user logins are inserted into the ''users'' table. It is not mandatory, but skipping this step will prevent the user interface to trace who does what.   * user logins are inserted into the ''users'' table. It is not mandatory, but skipping this step will prevent the user interface to trace who does what.
   * Users are assigned to groups with //GRANT role TO user// commands.   * Users are assigned to groups with //GRANT role TO user// commands.
  
 +==== Script for tables and sequences ====
 Here is a skeleton of an SQL script that grants all rights to the ''mailusers'' group. The administrator can use this as a starting point and remove specific access rights to particular groups of users. Here is a skeleton of an SQL script that grants all rights to the ''mailusers'' group. The administrator can use this as a starting point and remove specific access rights to particular groups of users.
 <code sql> <code sql>
Line 50: Line 51:
  
 </code> </code>
 +
 +==== Functions ====
 +Special care must be taken with functions since the execute privilege is granted to PUBLIC (every user) by default. In order to restrict the rights to use functions, the administrator should first revoke that privilege:
 +<code sql>
 +REVOKE EXECUTE ON FUNCTION
 + trash_msg(int, int),
 + trash_msg_set(int[], int),
 + untrash_msg(int, int),
 + delete_msg(int),
 + delete_msg_set(int[])
 +FROM public;
 +</code>
 +
 +It is especially interesting to remove the right to call delete_msg() on all or specific users to prevent accidental deletion of messages when the local policy it to never delete any mail.
  
schema_0_9_10_grants.1226164596.txt.gz · Last modified: 2008/11/08 17:16 by daniel