Documentation / Storage Parameters / View options
security_invoker
security_invoker
This option causes the underlying base relations to be checked against the privileges of the user of the view rather than the view owner. See the notes below for full details.
Reading PostgreSQL 18.6.
Description
This option causes the underlying base relations to be checked against the privileges of the user of the view rather than the view owner. See the notes below for full details.
- Applies to
- View options
- Value type
- boolean
Usage
WITH (security_invoker = value)View options
Views do not store query results. Set these security or update semantics with CREATE VIEW WITH or ALTER VIEW.
Security semantics
If the view has the security_invoker property set to true , access to the underlying base relations is determined by the permissions of the user executing the query, rather than the view owner. Thus, the user of a security invoker view must have the relevant permissions on the view and its underlying base relations.
If any of the underlying base relations is a security invoker view, it will be treated as if it had been accessed directly from the original query. Thus, a security invoker view will always check its underlying base relations using the permissions of the current user, even if it is accessed from a view without the security_invoker property.
If any of the underlying base relations has row-level security enabled, then by default, the row-level security policies of the view owner are applied, and access to any additional relations referred to by those policies is determined by the permissions of the view owner. However, if the view has security_invoker set to true , then the policies and permissions of the invoking user are used instead, as if the base relations had been referenced directly from the query using the view.
Functions called in the view are treated the same as if they had been called directly from the query using the view. Therefore, the user of a view must have permissions to call all functions used by the view. Functions in the view are executed with the privileges of the user executing the query or the function owner, depending on whether the functions are defined as SECURITY INVOKER or SECURITY DEFINER . Thus, for example, calling CURRENT_USER directly in a view will always return the invoking user, not the view owner. This is not affected by the view's security_invoker setting, and so a view with security_invoker set to false is not equivalent to a SECURITY DEFINER function and those concepts should not be confused.
Note that the user performing the insert, update or delete on the view must have the corresponding insert, update or delete privilege on the view. In addition, by default, the view's owner must have the relevant privileges on the underlying base relations, whereas the user performing the update does not need any permissions on the underlying base relations (see Section 39.5 ). However, if the view has security_invoker set to true , the user performing the update, rather than the view owner, must have the relevant privileges on the underlying base relations.
Related entries
Documentation and source
Source build
- Version
- 18.6
- Build
- Local English manual 18.6
- Source fingerprint
eb6c2292fdf28e1b4635ab478eec3919411cdf4a6c07553387870e26201f3744
Related entries
check_optioncheck_optionsecurity_barriersecurity_barrier
Back to Storage Parameters · Recorded in PostgreSQL 15 through 20; the first sample is not necessarily its introduction.