-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: SHOW GRANTS inherited by virtue of role membership #97299
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Comments
fabiog1901
added
the
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
label
Feb 17, 2023
rafiss
added
the
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
label
Feb 17, 2023
I think if we made the change, the |
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 5, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 6, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 6, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 6, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
craig bot
pushed a commit
that referenced
this issue
Jun 8, 2023
104119: sql: SHOW GRANTS includes inherited roles r=postamar a=postamar Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes #97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees. Co-authored-by: Marius Posta <[email protected]>
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 8, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
postamar
pushed a commit
to postamar/cockroach
that referenced
this issue
Jun 8, 2023
Previously, SHOW GRANTS would only list explicitly-granted privileges. This commit changes its output to include privileges inherited by role membership. Consider for example: CREATE DATABASE d1; CREATE ROLE r1; CREATE USER u1; GRANT r1 TO u1; SET database = d1; CREATE TABLE t1 (id INT8); GRANT ALL ON TABLE t1 TO r1; We want `SHOW GRANTS ON TABLE t1 FOR u1` to list the ALL privilege that u1 inherits from r1. For this purpose this commit also adds a new `kv_inherited_role_members` virtual table in `crdb_internal` which is essentially a recursive self-join of `system.role_members` run by the node user. This commit also changes the output of `SHOW GRANTS ON ROLE` to list both explicit and implicit grantees: the former are the direct result of a `GRANT ... TO ...` statement, the latter comprise also all the roles which inherit the privileges following further role membership relationships. For this purpose it also uses the new virtual table and therefore the current user no longer requires SELECT privileges on the `system.role_members` table. Fixes cockroachdb#97299. Release note (sql change): SHOW GRANTS now lists not just privileges explicitly granted to each role, but also roles which inherit from those. SHOW GRANTS ON ROLE statements no longer require any privileges and also lists implicit grantees.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
SHOW GRANTS
currently only lists explicitly granted privileges. This FR is to extend the list to privileges inherited by role membership. Example below:Starting point:
Currently, it shows no grants for u1:
Envisioned - see last column so you have that extra info
Slack
Jira issue: CRDB-24622
gz#16111
Epic CRDB-27601
The text was updated successfully, but these errors were encountered: