Restrict access to data
The RESTRICT command denies permission on a resource to the role.
The user is denied access even if the privilege has been granted directly to the role or if it was inherited.
The UNRESTRICT command removes any restrictions the role has on a database resource.
|
Regardless of how you use |
The following example uses the RESTRICT command:
-
Start a
cqlshsession using aSUPERUSERrole:cqlsh -u <username>Using the default
cassandrarole can degrade performance because all requests, including login, are executed with consistencyQUORUM.When you install HCD, it creates a
cassandrasuperuser role in the database, and HCD runs as this user. Don’t use the defaultcassandrarole in production because it is a security risk. Instead, create a new superuser role for running HCD. -
Create a role with the
LOGINoption enabled and theSUPERUSERoption disabled:CREATE ROLE IF NOT EXISTS db_admin WITH superuser = false AND login = true AND password = 'anypasswordwilldo';A password is required for internally authenticated roles, but not for roles using LDAP or OIDC authentication.
-
Restrict the role from accessing the data in the
cyclingkeyspace:RESTRICT TRUNCATE, UPDATE, SELECT ON KEYSPACE cycling TO db_admin; -
Verify the restriction:
SELECT role, resource, restricted FROM system_auth.role_permissions WHERE role = 'db_admin';The results show the permissions denied to the role:
role | resource | restricted ----------+--------------+---------------------- db_admin | data/cycling | {'MODIFY', 'SELECT'} (1 rows)