From f79e8b3a0d3412f09dcb7285f35cffa2ba107530 Mon Sep 17 00:00:00 2001 From: Ayantika19 Date: Mon, 14 Oct 2024 11:10:02 +0530 Subject: [PATCH] CASSANDRA-18868 Added documentation of granting permissions for all tables in a keyspace --- .../grant_permission_all_tables_statement.bnf | 2 ++ .../examples/CQL/grant_alter_all_tables.cql | 1 + .../examples/CQL/grant_drop_all_tables.cql | 1 + .../examples/CQL/grant_modify_all_tables.cql | 1 + .../pages/developing/cql/security.adoc | 36 +++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 doc/modules/cassandra/examples/BNF/grant_permission_all_tables_statement.bnf create mode 100644 doc/modules/cassandra/examples/CQL/grant_alter_all_tables.cql create mode 100644 doc/modules/cassandra/examples/CQL/grant_drop_all_tables.cql create mode 100644 doc/modules/cassandra/examples/CQL/grant_modify_all_tables.cql diff --git a/doc/modules/cassandra/examples/BNF/grant_permission_all_tables_statement.bnf b/doc/modules/cassandra/examples/BNF/grant_permission_all_tables_statement.bnf new file mode 100644 index 0000000000..82d08801ac --- /dev/null +++ b/doc/modules/cassandra/examples/BNF/grant_permission_all_tables_statement.bnf @@ -0,0 +1,2 @@ +grant_permission_statement ::= GRANT permission ON ALL TABLES IN KEYSPACE keyspace_name TO user_name; +permission ::= CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE | UNMASK | SELECT_MASKED diff --git a/doc/modules/cassandra/examples/CQL/grant_alter_all_tables.cql b/doc/modules/cassandra/examples/CQL/grant_alter_all_tables.cql new file mode 100644 index 0000000000..808ce19f67 --- /dev/null +++ b/doc/modules/cassandra/examples/CQL/grant_alter_all_tables.cql @@ -0,0 +1 @@ +GRANT ALTER ON ALL TABLES IN KEYSPACE keyspace_name TO user_name; \ No newline at end of file diff --git a/doc/modules/cassandra/examples/CQL/grant_drop_all_tables.cql b/doc/modules/cassandra/examples/CQL/grant_drop_all_tables.cql new file mode 100644 index 0000000000..8b3d73a025 --- /dev/null +++ b/doc/modules/cassandra/examples/CQL/grant_drop_all_tables.cql @@ -0,0 +1 @@ +GRANT DROP ON ALL TABLES IN KEYSPACE keyspace_name TO user_name; \ No newline at end of file diff --git a/doc/modules/cassandra/examples/CQL/grant_modify_all_tables.cql b/doc/modules/cassandra/examples/CQL/grant_modify_all_tables.cql new file mode 100644 index 0000000000..81d7cce781 --- /dev/null +++ b/doc/modules/cassandra/examples/CQL/grant_modify_all_tables.cql @@ -0,0 +1 @@ +GRANT MODIFY ON ALL TABLES IN KEYSPACE keyspace_name TO user_name; \ No newline at end of file diff --git a/doc/modules/cassandra/pages/developing/cql/security.adoc b/doc/modules/cassandra/pages/developing/cql/security.adoc index 208dfd383a..103903961f 100644 --- a/doc/modules/cassandra/pages/developing/cql/security.adoc +++ b/doc/modules/cassandra/pages/developing/cql/security.adoc @@ -634,6 +634,42 @@ include::cassandra:example$CQL/grant_describe.cql[] This grants any user with the `role_admin` role permission to view any and all roles in the system with a `LIST ROLES` statement. +==== GRANT PERMISSION FOR ALL TABLES IN A KEYSPACE + +Granting permission to all tables and user types in a keyspace uses +`GRANT ` statement: + +[source,bnf] +---- +include::example$BNF/grant_permission_all_tables_statement.bnf[] +---- + +For example: + +[source,cql] +---- +include::example$CQL/grant_drop_all_tables.cql[] +---- + +This command grants any user with the `user_name` role permission to execute +`DROP` statements on all the tables across the keyspace `keyspace_name` + +[source,cql] +---- +include::example$CQL/grant_alter_all_tables.cql[] +---- + +This command grants any user with the `user_name` role permission to execute +`ALTER` statements on all the tables across the keyspace `keyspace_name` + +[source,cql] +---- +include::example$CQL/grant_modify_all_tables.cql[] +---- + +This command grants any user with the `user_name` role permission to execute +`MODIFY` statements on all the tables across the keyspace `keyspace_name` + ==== GRANT ALL When the `GRANT ALL` form is used, the appropriate set of permissions is