pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add support for security invoker views.
Date: Tue, 22 Mar 2022 10:31:39 +0000
Message-ID: <E1nWbne-000qzv-L0@gemulon.postgresql.org> (raw)

Add support for security invoker views.

A security invoker view checks permissions for accessing its
underlying base relations using the privileges of the user of the
view, rather than the privileges of the view owner. Additionally, if
any of the base relations are tables with RLS enabled, the policies of
the user of the view are applied, rather than those of the view owner.

This allows views to be defined without giving away additional
privileges on the underlying base relations, and matches a similar
feature available in other database systems.

It also allows views to operate more naturally with RLS, without
affecting the assignments of policies to users.

Christoph Heiss, with some additional hacking by me. Reviewed by
Laurenz Albe and Wolfgang Walther.

Discussion: https://postgr.es/m/b66dd6d6-ad3e-c6f2-8b90-47be773da240%40cybertec.at

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7faa5fc84bf46ea6c543993cffb8be64dff60d25

Modified Files
--------------
doc/src/sgml/ref/alter_view.sgml              |  12 +-
doc/src/sgml/ref/create_policy.sgml           |   4 +-
doc/src/sgml/ref/create_view.sgml             | 105 +++++++++--
doc/src/sgml/ref/lock.sgml                    |  13 +-
doc/src/sgml/rules.sgml                       |  11 +-
src/backend/access/common/reloptions.c        |  11 ++
src/backend/commands/lockcmds.c               |  19 +-
src/backend/rewrite/rewriteHandler.c          |  18 +-
src/backend/utils/cache/relcache.c            |  73 +++++---
src/include/utils/rel.h                       |  11 ++
src/test/regress/expected/create_view.out     |  46 ++++-
src/test/regress/expected/lock.out            |  66 +++++++
src/test/regress/expected/rowsecurity.out     | 257 +++++++++++++++++++++++++-
src/test/regress/expected/rules.out           |  30 +++
src/test/regress/expected/updatable_views.out | 237 ++++++++++++++++++++++++
src/test/regress/sql/create_view.sql          |  22 ++-
src/test/regress/sql/lock.sql                 |  49 +++++
src/test/regress/sql/rowsecurity.sql          | 122 ++++++++++++
src/test/regress/sql/rules.sql                |  28 +++
src/test/regress/sql/updatable_views.sql      | 180 ++++++++++++++++++
20 files changed, 1239 insertions(+), 75 deletions(-)



Message-ID: <E1nWbne-000qzv-L0@gemulon.postgresql.org>
Permalink:  ../E1nWbne-000qzv-L0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nWbne-000qzv-L0@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Add support for security invoker views.
  In-Reply-To: <E1nWbne-000qzv-L0@gemulon.postgresql.org>
  References: <E1nWbne-000qzv-L0@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox