mirror of
https://github.com/postgres/postgres.git
synced 2025-12-22 17:42:17 +03:00
Add support for restrictive RLS policies
We have had support for restrictive RLS policies since 9.5, but they were only available through extensions which use the appropriate hooks. This adds support into the grammer, catalog, psql and pg_dump for restrictive RLS policies, thus reducing the cases where an extension is necessary. In passing, also move away from using "AND"d and "OR"d in comments. As pointed out by Alvaro, it's not really appropriate to attempt to make verbs out of "AND" and "OR", so reword those comments which attempted to. Reviewed By: Jeevan Chalke, Dean Rasheed Discussion: https://postgr.es/m/20160901063404.GY4028@tamriel.snowman.net
This commit is contained in:
@@ -22,6 +22,7 @@ PostgreSQL documentation
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable>
|
||||
[ AS { PERMISSIVE | RESTRICTIVE } ]
|
||||
[ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
|
||||
[ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ]
|
||||
[ USING ( <replaceable class="parameter">using_expression</replaceable> ) ]
|
||||
@@ -119,6 +120,33 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">PERMISSIVE</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify that the policy is to be created as a permissive policy.
|
||||
All permissive policies which are applicable to a given query will
|
||||
be combined together using the boolean "OR" operator. By creating
|
||||
permissive policies, administrators can add to the set of records
|
||||
which can be accessed. Policies are PERMISSIVE by default.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">RESTRICTIVE</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify that the policy is to be created as a restrictive policy.
|
||||
All restrictive policies which are applicable to a given query will
|
||||
be combined together using the boolean "AND" operator. By creating
|
||||
restrictive policies, administrators can reduce the set of records
|
||||
which can be accessed as all restrictive policies must be passed for
|
||||
each record.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">command</replaceable></term>
|
||||
<listitem>
|
||||
@@ -390,6 +418,16 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
|
||||
keys) instead of keys with external meanings.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that there needs to be at least one permissive policy to grant
|
||||
access to records before restrictive policies can be usefully used to
|
||||
reduce that access. If only restrictive policies exist, then no records
|
||||
will be accessible. When a mix of permissive and restrictive policies
|
||||
are present, a record is only accessible if at least one of the
|
||||
permissive policies passes, in addition to all the restrictive
|
||||
policies.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Generally, the system will enforce filter conditions imposed using
|
||||
security policies prior to qualifications that appear in user queries,
|
||||
|
||||
Reference in New Issue
Block a user