mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
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
This commit is contained in:
@@ -398,6 +398,7 @@ typedef struct ViewOptions
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
bool security_barrier;
|
||||
bool security_invoker;
|
||||
ViewOptCheckOption check_option;
|
||||
} ViewOptions;
|
||||
|
||||
@@ -411,6 +412,16 @@ typedef struct ViewOptions
|
||||
(relation)->rd_options ? \
|
||||
((ViewOptions *) (relation)->rd_options)->security_barrier : false)
|
||||
|
||||
/*
|
||||
* RelationHasSecurityInvoker
|
||||
* Returns true if the relation has the security_invoker property set.
|
||||
* Note multiple eval of argument!
|
||||
*/
|
||||
#define RelationHasSecurityInvoker(relation) \
|
||||
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
|
||||
(relation)->rd_options ? \
|
||||
((ViewOptions *) (relation)->rd_options)->security_invoker : false)
|
||||
|
||||
/*
|
||||
* RelationHasCheckOption
|
||||
* Returns true if the relation is a view defined with either the local
|
||||
|
||||
Reference in New Issue
Block a user