doc - improve description of default privileges
doc - improve description of default privileges
I have not found a convenient presentation of the default privileges for different objects, and how to display them (if possible, not always). The information is partly provided within the GRANT description, and not very explicit: eg it is said that owners have all possible perms, but which they are is not said explicitely, although they are implied by the different GRANT sysnopsys. Then some objects are given perms for the PUBLIC. The attached patch tries to improve the documentation, in particular with an added table to summarizes my findings, so that they are recorded somewhere. -- Fabien.
Re: doc - improve description of default privileges
> I have not found a convenient presentation of the default privileges for > different objects, and how to display them (if possible, not always). > > The information is partly provided within the GRANT description, and not very > explicit: eg it is said that owners have all possible perms, but which they > are is not said explicitely, although they are implied by the different GRANT > sysnopsys. Then some objects are given perms for the PUBLIC. > > The attached patch tries to improve the documentation, in particular with an > added table to summarizes my findings, so that they are recorded somewhere. The attached fixes the tablespace entry that I forgot to fill in full. -- Fabien.
Re[2]: doc - improve description of default privileges
От:
"Bradley DeJong" <bpd0018@gmail.com>
Дата:
Hi Fabien, Thanks for writing this up - in particular the psql backslash commands. comments on the patch ... 1) I think that adding the "This privilege is abbreviated ... when displayed." lines to the privilege descriptions is redundant. The abbreviations are already listed after the "The entries shown by \dp are interpreted thus:" line. Just change that line to something like "The entries shown by the psql backslash commands, like \dp, are interpreted thus:". 2) I think that the psql command table should go with the current text on "Use psql's \dp command to obtain ..." rather than in the Examples section. It seems like changing the "For non-table objects there are other \d commands ..." line to an introductory comment like "The following table lists the \d commands that are used for non-table objects along with the default privileges granted to the object's owner and PUBLIC. 3) The table title, "Default hardcoded access privileges per object's type", seems incomplete because it does not mention the psql commands part of the table. ------ Original Message ------ From: "Fabien COELHO" To: "PostgreSQL Developers" Sent: 8/4/2018 4:40:33 AM Subject: Re: doc - improve description of default privileges > >>I have not found a convenient presentation of the default privileges >>for different objects, and how to display them (if possible, not >>always). >> >>The information is partly provided within the GRANT description, and >>not very explicit: eg it is said that owners have all possible perms, >>but which they are is not said explicitely, although they are implied >>by the different GRANT sysnopsys. Then some objects are given perms >>for the PUBLIC. >> >>The attached patch tries to improve the documentation, in particular >>with an added table to summarizes my findings, so that they are >>recorded somewhere. > >The attached fixes the tablespace entry that I forgot to fill in full. > >-- Fabien.
Re[2]: doc - improve description of default privileges
Hello Bradley, > comments on the patch ... Thanks for the review. > 1) I think that adding the "This privilege is abbreviated ... when > displayed." lines to the privilege descriptions is redundant. The > abbreviations are already listed after the "The entries shown by \dp are > interpreted thus:" line. Just change that line to something like "The entries > shown by the psql backslash commands, like \dp, are interpreted thus:". Ok, removed. > 2) I think that the psql command table should go with the current text on > "Use psql's \dp command to obtain ..." rather than in the Examples section. > It seems like changing the "For non-table objects there are other \d commands > ..." line to an introductory comment like "The following table lists the \d > commands that are used for non-table objects along with the default > privileges granted to the object's owner and PUBLIC. Ok, moved to the previous section. > 3) The table title, "Default hardcoded access privileges per object's type", > seems incomplete because it does not mention the psql commands part of the > table. Ok, added reference to psql backslash commands in title. Find v3 attached. -- Fabien.
Re[3]: doc - improve description of default privileges
От:
"Bradley DeJong" <bpd0018@gmail.com>
Дата:
on 2018-08-30, Fabien Coelho wrote ... > ... Find v3 attached. ... Hi Fabien, As we're coming up on the end of this commitfest ... Is the reviewer supposed to move this to "ready for committer" or is the author supposed to do that? Is the reviewer supposed to explicitly state "I've looked at your v3 patch and have no further suggestions" (which is true) or is a lack of additional comments normally taken as acceptance? Cheers.
Re: Re[3]: doc - improve description of default privileges
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Bradley DeJong" writes: > Is the reviewer supposed to move this to "ready for committer" or is the > author supposed to do that? The reviewer does that, indicating signoff. regards, tom lane
Re: Re[3]: doc - improve description of default privileges
От:
Brad DeJong <bpd0018@gmail.com>
Дата:
On 2018-09-12 Tom Lane wrote ...
> The reviewer does that, indicating signoff.
Thanks. I have now changed the status to "Ready for Committer".
Re: doc - improve description of default privileges
От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
Some thoughts: We should keep the GRANT reference page about GRANT. There is a section about Privileges in the Data Definition chapter, which we could use to expand on general concepts. The ALTER DEFAULT PRIVILEGES reference page would be another place this could be put. The Owner column is redundant, because it's always all applicable privileges. (Having this column would give the impression that it's not always all privileges, so it would be confusing.) Privileges should be listed using their full name (e.g., "SELECT"), not their internal abbreviation letter. The psql commands seem out of place here. If you want to learn about how to use psql, you can go to the psql documentation. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: doc - improve description of default privileges
От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2018-Sep-28, Peter Eisentraut wrote: > The psql commands seem out of place here. If you want to learn about > how to use psql, you can go to the psql documentation. There is a legitimate point in doing this, though, since the GRANT page is already explaining how does psql display privileges. Maybe the right solution is move that stuff all to the psql documentation, and alter the GRANT page to list privileges in terms of their names rather than the way psql displays them. (And of course add cross-links, so that it all makes sense.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: doc - improve description of default privileges
От:
Fabien COELHO <coelho@cri.ensmp.fr>
Дата:
> The Owner column is redundant, because it's always all applicable
> privileges. (Having this column would give the impression that it's not
> always all privileges, so it would be confusing.)
The reason I put the owner column is to show (1) the privileges that apply
to the objects (i.e. what is under "ALL") and (2) whether public's
privileges are the same or not, because there are subtles differences, so
I think it is interesting to have them side by side somewhere.
> Privileges should be listed using their full name (e.g., "SELECT"), not
> their internal abbreviation letter.
Hmmm... the psql commands listed in the table output the abbreviated
letters. Using the words would result in a large table, but maybe it
could use multiline cells.
> The psql commands seem out of place here. If you want to learn about
> how to use psql, you can go to the psql documentation.
The information about how to display the permissions is currently not
easily available, I had to test/look for it, noticed that it is not
accessible on some objects, so ISTM that it is useful to have it
somewhere.
Basically your points suggest that the table is maybe in the wrong place
and could be improved.
About the place, there is no simple choice:
- backslash commands are "psql" specific
- abbreviated letters are aclitem function specific, which
happend to be used by psql.
- full names are SQL specific (GRANT)
- default permissions are object specific and can be modified...
Which means that the information tends to be scattered everywhere and
overall pretty unclear unless you have read all the pages, hence my
proposal to put some unified summary somewhere with all the relevant
information. Any choice will have its downside, and removing information
to better suit one place means that my point of having some kind of
summary in one place is lost, which is the initial motivation for this
patch.
--
Fabien.
Re: doc - improve description of default privileges
On Fri, Sep 28, 2018 at 04:15:13PM -0300, Alvaro Herrera wrote: > There is a legitimate point in doing this, though, since the GRANT page > is already explaining how does psql display privileges. Maybe the right > solution is move that stuff all to the psql documentation, and alter the > GRANT page to list privileges in terms of their names rather than the > way psql displays them. (And of course add cross-links, so that it all > makes sense.) This point is interesting, and that looks rather right to me. I looked at the patch and listing psql commands on the page for GRANT is a strange concept in my opinion. Moved to next CF. -- Michael
Re: doc - improve description of default privileges
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Progress on this patch seems to be blocked on the question of whether we want to keep enlarging the amount of psql-specific information in the GRANT reference page, or move that all somewhere else. FWIW, I think I agree with Peter's position that moving it somewhere else is the better option. Section 5.6 "Privileges" seems like a reasonable choice. One reason for preferring that is that I don't think putting a
Re: doc - improve description of default privileges
Hello Tom,
Thanks for this precise feedback.
> Progress on this patch seems to be blocked on the question of whether
> we want to keep enlarging the amount of psql-specific information
> in the GRANT reference page, or move that all somewhere else.
Yep.
> FWIW, I think I agree with Peter's position that moving it somewhere
> else is the better option. Section 5.6 "Privileges" seems like a
> reasonable choice.
Ok.
> * Perhaps we could fix Peter's complaint about the "Owner" column by
> relabeling it "All Privileges".
Ok.
> I'd be inclined to label the last column "Default PUBLIC Privileges",
> too, if we can fit that in.
Ok.
> * The phrase "relation-like objects" seems way too vague, especially since
> one has to read it as excluding sequences, which surely are relations for
> most purposes. Is there a good reason not to just leave that entry as
> "TABLE", full stop? Or maybe it could be "TABLE, VIEW, etc" or some such.
Ok.
> * I don't think the use of "hardcoded" adds anything.
Hmmm. As "default privileges" can be altered, the point is to describe the
"default default privileges", but this looks absurd, hence the look for
something to add the idea that there is another one. ISTM that removing
"hardcoded" without replacing it makes the thing slightly ambiguous.
No big deal.
> * Is it worth adding another table matching privilege names ("INSERT")
> with their aclitem letters ("a"), rather than having the semi-formal
> format currently appearing in grant.sgml?
Indeed I thought about that, because the description is not easy to read.
> There's also some related material in 9.25 with the aclitem functions;
> it'd be worth unifying that too maybe.
I've put a reference to it at least.
Attached v4:
- moves the table to the privileges section
- updates the table column headers
- adds a privilege/aclitem letter mapping table
- adds some appropriate links towards psql & aclitem
--
Fabien.Re: doc - improve description of default privileges
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Fabien COELHO writes:
> Attached v4:
> - moves the table to the privileges section
> - updates the table column headers
> - adds a privilege/aclitem letter mapping table
> - adds some appropriate links towards psql & aclitem
TBH, I don't think this goes nearly far enough. It seems like it
is making the fragmentation of aclitem information worse not better.
I feel if we're going to do anything, we should put a unified description
of privileges and aclitem-reading into section 5.6, and take that material
out of the various places where it lives now. Like the attached, in which
I failed to resist the temptation to wordsmith some stuff as well as move
it around.
regards, tom lane
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index c134bca..18c38e4 100644
*** a/doc/src/sgml/catalogs.sgml
--- b/doc/src/sgml/catalogs.sgml
*************** SCRAM-SHA-256$<iteration
*** 1973,1982 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 1973,1979 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 2679,2688 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 2676,2682 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 3491,3500 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 3485,3491 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 3587,3596 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 3578,3584 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 4052,4060 ****
The initial access privileges; see
! and
!
! for details
--- 4040,4046 ----
The initial access privileges; see
! for details
*************** SCRAM-SHA-256$<iteration
*** 4179,4188 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 4165,4171 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 4319,4328 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 4302,4308 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 4386,4395 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 4366,4372 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 5396,5405 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 5373,5379 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 6810,6819 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 6784,6790 ----
aclitem[]
! Access privileges; see for details
*************** SCRAM-SHA-256$<iteration
*** 7923,7932 ****
aclitem[]
! Access privileges; see
! and
!
! for details
--- 7894,7900 ----
aclitem[]
! Access privileges; see for details
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index bfe89ef..f0cf75f 100644
*** a/doc/src/sgml/ddl.sgml
--- b/doc/src/sgml/ddl.sgml
*************** ALTER TABLE products RENAME TO items;
*** 1396,1401 ****
--- 1396,1405 ----
REVOKE
+
+ ACL
+
+
When an object is created, it is assigned an owner. The
owner is normally the role that executed the creation statement.
*************** ALTER TABLE products RENAME TO items;
*** 1413,1423 ****
EXECUTE, and USAGE.
The privileges applicable to a particular
object vary depending on the object's type (table, function, etc).
! For complete information on the different types of privileges
! supported by PostgreSQL, refer to the
! reference
! page. The following sections and chapters will also show you how
! those privileges are used.
--- 1417,1425 ----
EXECUTE, and USAGE.
The privileges applicable to a particular
object vary depending on the object's type (table, function, etc).
! More detail about the meanings of these privileges is provided below.
! The following sections and chapters will also show you how
! these privileges are used.
*************** ALTER TABLE products RENAME TO items;
*** 1435,1441 ****
! To assign privileges, the GRANT command is
used. For example, if joe is an existing role, and
accounts is an existing table, the privilege to
update the table can be granted with:
--- 1437,1443 ----
! To assign privileges, the command is
used. For example, if joe is an existing role, and
accounts is an existing table, the privilege to
update the table can be granted with:
*************** GRANT UPDATE ON accounts TO joe;
*** 1456,1462 ****
To revoke a privilege, use the fittingly named
! REVOKE command:
REVOKE ALL ON accounts FROM PUBLIC;
--- 1458,1464 ----
To revoke a privilege, use the fittingly named
! command:
REVOKE ALL ON accounts FROM PUBLIC;
*************** REVOKE ALL ON accounts FROM PUBLIC;
*** 1478,1483 ****
--- 1480,1983 ----
privilege. For details see the and
reference pages.
+
+
+ The available privileges are:
+
+
+
+ SELECT
+
+
+ Allows from
+ any column, or specific column(s), of a table, view, materialized
+ view, or other table-like object.
+ Also allows use of TO.
+ This privilege is also needed to reference existing column values in
+ or .
+ For sequences, this privilege also allows the use of the
+ currval function.
+ For large objects, this privilege allows the object to be read.
+
+
+
+
+
+ INSERT
+
+
+ Allows of a new row into a table, view,
+ etc. Can be granted on specific column(s), in which case
+ only those columns may be assigned to in the INSERT
+ command (other columns will therefore receive default values).
+ Also allows use of FROM.
+
+
+
+
+
+ UPDATE
+
+
+ Allows of any
+ column, or specific column(s), of a table, view, etc.
+ (In practice, any nontrivial UPDATE command will
+ require SELECT privilege as well, since it must
+ reference table columns to determine which rows to update, and/or to
+ compute new values for columns.)
+ SELECT ... FOR UPDATE
+ and SELECT ... FOR SHARE
+ also require this privilege on at least one column, in addition to the
+ SELECT privilege. For sequences, this
+ privilege allows the use of the nextval and
+ setval functions.
+ For large objects, this privilege allows writing or truncating the
+ object.
+
+
+
+
+
+ DELETE
+
+
+ Allows of a row from a table, view, etc.
+ (In practice, any nontrivial DELETE command will
+ require SELECT privilege as well, since it must
+ reference table columns to determine which rows to delete.)
+
+
+
+
+
+ TRUNCATE
+
+
+ Allows on a table, view, etc.
+
+
+
+
+
+ REFERENCES
+
+
+ Allows creation of a foreign key constraint referencing a
+ table, or specific column(s) of a table.
+
+
+
+
+
+ TRIGGER
+
+
+ Allows creation of a trigger on a table, view, etc.
+
+
+
+
+
+ CREATE
+
+
+ For databases, allows new schemas and publications to be created within
+ the database.
+
+
+ For schemas, allows new objects to be created within the schema.
+ To rename an existing object, you must own the
+ object and have this privilege for the containing
+ schema.
+
+
+ For tablespaces, allows tables, indexes, and temporary files to be
+ created within the tablespace, and allows databases to be created that
+ have the tablespace as their default tablespace. (Note that revoking
+ this privilege will not alter the placement of existing objects.)
+
+
+
+
+
+ CONNECT
+
+
+ Allows the grantee to connect to the database. This
+ privilege is checked at connection startup (in addition to checking
+ any restrictions imposed by pg_hba.conf).
+
+
+
+
+
+ TEMPORARY
+
+
+ Allows temporary tables to be created while using the database.
+
+
+
+
+
+ EXECUTE
+
+
+ Allows calling a function or procedure, including use of
+ any operators that are implemented on top of the function. This is the
+ only type of privilege that is applicable to functions and procedures.
+
+
+
+
+
+ USAGE
+
+
+ For procedural languages, allows use of a language for
+ the creation of functions in that language. This is the only type
+ of privilege that is applicable to procedural languages.
+
+
+ For schemas, allows access to objects contained in a
+ schema (assuming that the objects' own privilege requirements are
+ also met). Essentially this allows the grantee to look up
+ objects within the schema. Without this permission, it is still
+ possible to see the object names, e.g. by querying system catalogs.
+ Also, after revoking this permission, existing sessions might have
+ statements that have previously performed this lookup, so this is not
+ a completely secure way to prevent object access.
+
+
+ For sequences, this privilege allows the use of the
+ currval and nextval functions.
+
+
+ For types and domains, this privilege allows the use of the type or
+ domain in the creation of tables, functions, and other schema objects.
+ (Note that it does not control general usage of the type,
+ such as values of the type appearing in queries. It only prevents
+ objects from being created that depend on the type. The main purpose of
+ this privilege is controlling which users create dependencies on a type,
+ which could prevent the owner from changing the type later.)
+
+
+ For foreign-data wrappers, this privilege allows creation of
+ new servers using the foreign-data wrapper.
+
+
+ For servers, this privilege allows creation of foreign tables using
+ the server. Grantees may also create, alter, or drop their own
+ user mappings associated with that server.
+
+
+
+
+
+ The privileges required by other commands are listed on the
+ reference page of the respective command.
+
+
+
+ PostgreSQL grants privileges on some types of objects to
+ PUBLIC by default when the objects are created.
+ No privileges are granted to PUBLIC by default on
+ tables,
+ table columns,
+ sequences,
+ foreign data wrappers,
+ foreign servers,
+ large objects,
+ schemas,
+ or tablespaces.
+ For other types of objects, the default privileges
+ granted to PUBLIC are as follows:
+ CONNECT and TEMPORARY (create
+ temporary tables) privileges for databases;
+ EXECUTE privilege for functions and procedures; and
+ USAGE privilege for languages and data types
+ (including domains).
+ The object owner can, of course, REVOKE
+ both default and expressly granted privileges. (For maximum
+ security, issue the REVOKE in the same transaction that
+ creates the object; then there is no window in which another user
+ can use the object.)
+ Also, these default privilege settings can be overridden using the
+ command.
+
+
+
+ shows the one-letter
+ abbreviations that are used for these privilege types in
+ ACL (Access Control List) values.
+ You will see these letters in the output of the
+ commands listed below, or when looking at ACL columns of system catalogs.
+
+
+ Re: doc - improve description of default privileges
От:
Alvaro Herrera <alvherre@2ndquadrant.com>
Дата:
On 2018-Nov-30, Tom Lane wrote: > I feel if we're going to do anything, we should put a unified description > of privileges and aclitem-reading into section 5.6, and take that material > out of the various places where it lives now. Like the attached, in which > I failed to resist the temptation to wordsmith some stuff as well as move > it around. I looked at the psql manpage and the HTML rendering of section 5.6 and it all looks good to me. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: doc - improve description of default privileges
От:
Fabien COELHO <coelho@cri.ensmp.fr>
Дата:
>> I feel if we're going to do anything, we should put a unified description >> of privileges and aclitem-reading into section 5.6, and take that material >> out of the various places where it lives now. Like the attached, in which >> I failed to resist the temptation to wordsmith some stuff as well as move >> it around. > > I looked at the psql manpage and the HTML rendering of section 5.6 and > it all looks good to me. Indeed, this looks great, a precise and full description of privileges just in one place. -- Fabien.
Re: doc - improve description of default privileges
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Fabien COELHO writes: >>> I feel if we're going to do anything, we should put a unified description >>> of privileges and aclitem-reading into section 5.6, and take that material >>> out of the various places where it lives now. Like the attached, in which >>> I failed to resist the temptation to wordsmith some stuff as well as move >>> it around. >> I looked at the psql manpage and the HTML rendering of section 5.6 and >> it all looks good to me. > Indeed, this looks great, a precise and full description of privileges > just in one place. Pushed (with a little bit more tweaking). regards, tom lane
Re: doc - improve description of default privileges
От:
Fabien COELHO <coelho@cri.ensmp.fr>
Дата:
>>> I looked at the psql manpage and the HTML rendering of section 5.6 and >>> it all looks good to me. > >> Indeed, this looks great, a precise and full description of privileges >> just in one place. > > Pushed (with a little bit more tweaking). Thanks for the rewrite, extensions, improvements and final push. -- Fabien.