ScyllaDB University LIVE, FREE Virtual Training Event | March 21
Register for Free
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB Open Source ScyllaDB for Administrators Security Grant Authorization CQL Reference

Caution

You're viewing documentation for a previous version. Switch to the latest stable version.

Grant Authorization CQL Reference¶

Authorization is the process by where users are granted permissions, which entitle them to access, or permission to change data on specific keyspaces, tables or an entire datacenter. Authorization for Scylla is done internally within Scylla and is not done with a third-party such as LDAP or OAuth. Granting permissions to users requires the use of a role such as a Database Administrator as well as enabling the CassandraAuthorizer. It also requires a user who has been authenticated.

This reference covers CQL specification version 3.3.1

Database Roles¶

Database roles should be used instead of USERS.

CQL uses database roles to represent users and groups of users. Syntactically, a role is defined by:

role_name: `identifier` | `string`

CREATE ROLE¶

Creating a role uses the CREATE ROLE statement:

create_role_statement: CREATE ROLE [ IF NOT EXISTS ] `role_name`
                     :     [ WITH `role_options` ]
role_options: `role_option` ( AND `role_option` )*
role_option: PASSWORD '=' `string`
           :| LOGIN '=' `boolean`
           :| SUPERUSER '=' `boolean`
           :| OPTIONS '=' `map_literal`

For instance:

CREATE ROLE new_role;
CREATE ROLE alice WITH PASSWORD = 'password_a' AND LOGIN = true;
CREATE ROLE bob WITH PASSWORD = 'password_b' AND LOGIN = true AND SUPERUSER = true;
CREATE ROLE carlos WITH OPTIONS = { 'custom_option1' : 'option1_value', 'custom_option2' : 99 };

Warning

It is highly recommended to set a password when creating a role with login privileges. If you are using password authentication and you create a role with LOGIN privileges and a blank PASSWORD or no password, the user assigned to this role will not be able to login to the database.

By default, roles do not possess LOGIN privileges or SUPERUSER status.

Permissions on database resources are granted to roles; types of resources include keyspaces, tables, functions, and roles themselves. Roles may be granted to other roles to create hierarchical permissions structures; in these hierarchies, permissions and SUPERUSER status are inherited, but the LOGIN privilege is not.

If a role has the LOGIN privilege, clients may identify as that role when connecting. For the duration of that connection, the client will acquire any roles and privileges granted to that role.

Only a client with the CREATE permission on the database roles resource may issue CREATE ROLE requests (see the relevant section below) unless the client is a SUPERUSER. Role management in Scylla is pluggable, and custom implementations may support only a subset of the listed options.

Role names should be quoted if they contain non-alphanumeric characters.

Setting credentials for internal authentication¶

Use the WITH PASSWORD clause to set a password for internal authentication, enclosing the password in single quotation marks.

If internal authentication has not been set up or the role does not have LOGIN privileges, the WITH PASSWORD clause is not necessary.

Creating a role conditionally¶

Attempting to create an existing role results in an invalid query condition unless the IF NOT EXISTS option is used. If the option is used and the role exists, the statement is a no-op:

CREATE ROLE other_role;
CREATE ROLE IF NOT EXISTS other_role;

ALTER ROLE¶

Altering role options uses the ALTER ROLE statement:

alter_role_statement: ALTER ROLE `role_name` WITH `role_options`

For instance:

ALTER ROLE bob WITH PASSWORD = 'PASSWORD_B' AND SUPERUSER = false;

Conditions on executing ALTER ROLE statements:

  • A client must have SUPERUSER status to alter the SUPERUSER status of another role

  • A client cannot alter the SUPERUSER status of any role it currently holds

  • A client can only modify certain properties of the role with which it identified at login (e.g. PASSWORD)

  • To modify properties of a role, the client must be granted ALTER permission on that role

DROP ROLE¶

Dropping a role uses the DROP ROLE statement:

drop_role_statement: DROP ROLE [ IF EXISTS ] `role_name`

DROP ROLE requires the client to have DROP permission on the role in question. In addition, client may not DROP the role with which it identified at login. Finally, only a client with SUPERUSER status may DROP another SUPERUSER role.

Attempting to drop a role that does not exist results in an invalid query condition unless the IF EXISTS option is used. If the option is used and the role does not exist, the statement is a no-op.

GRANT ROLE¶

Granting a role to another uses the GRANT ROLE statement:

grant_role_statement: GRANT `role_name` TO `role_name`

For instance:

GRANT report_writer TO alice;

This statement grants the report_writer role to alice. Any permissions granted to report_writer are also acquired by alice.

Roles are modelled as a directed acyclic graph, so circular grants are not permitted. The following examples result in error conditions:

GRANT role_a TO role_b;
GRANT role_b TO role_a;

GRANT role_a TO role_b;
GRANT role_b TO role_c;
GRANT role_c TO role_a;

REVOKE ROLE¶

Revoking a role uses the REVOKE ROLE statement:

revoke_role_statement: REVOKE `role_name` FROM `role_name`

For instance:

REVOKE report_writer FROM alice;

This statement revokes the report_writer role from alice. Any permissions that alice has acquired via the report_writer role are also revoked.

LIST ROLES¶

All the known roles (in the system or granted to the specific role) can be listed using the LIST ROLES statement:

list_roles_statement: LIST ROLES [ OF `role_name` ] [ NORECURSIVE ]

For instance:

LIST ROLES;

returns all known roles in the system, this requires DESCRIBE permission on the database roles resource. And:

LIST ROLES OF alice;

enumerates all roles granted to alice, including those transitively acquired. But:

LIST ROLES OF bob NORECURSIVE

lists all roles directly granted to bob without including any of the transitively acquired ones.

Users¶

Prior to the introduction of roles in Scylla 2.2, authentication and authorization were based around the concept of a USER. For backward compatibility, this syntax has been preserved. From Scylla 2.2 and onward, it is recommended to use roles.

CREATE USER¶

Creating a user uses the CREATE USER statement:

create_user_statement: CREATE USER [ IF NOT EXISTS ] [ WITH PASSWORD `string` ] [ `user_option` ]
user_option: SUPERUSER | NOSUPERUSER

For instance:

CREATE USER alice WITH PASSWORD 'password_a' SUPERUSER;
CREATE USER bob WITH PASSWORD 'password_b' NOSUPERUSER;

CREATE USER where the LOGIN option is true. So, the following pairs of statements are equivalent:

CREATE USER alice WITH PASSWORD 'password_a' SUPERUSER;
CREATE USER IF NOT EXISTS alice WITH PASSWORD 'password_a' SUPERUSER;
CREATE USER alice WITH PASSWORD 'password_a' NOSUPERUSER;
CREATE USER alice WITH PASSWORD 'password_a';

Warning

It is highly recommended to set a password when creating a role with login privileges. If you are using password authentication and you create a role with LOGIN privileges and a blank PASSWORD or no password, the user assigned to this role will not be able to login to the database.

ALTER USER¶

Altering the options of a user uses the ALTER USER statement:

alter_user_statement: ALTER USER `user_name` [ WITH PASSWORD `string` ] [ `user_option` ]

For instance:

ALTER USER alice WITH PASSWORD 'PASSWORD_A';
ALTER USER bob SUPERUSER;

DROP USER¶

Dropping a user uses the DROP USER statement:

drop_user_statement: DROP USER [ IF EXISTS ]

LIST USERS¶

Existing users can be listed using the LIST USERS statement:

list_users_statement: LIST USERS

Data Control¶

Permissions¶

Permissions on resources are granted to users; there are several different types of resources in Scylla, and each type is modelled hierarchically:

  • The hierarchy of Data resources, Keyspaces, and Tables has the structure ALL KEYSPACES -> KEYSPACE -> TABLE.

Permissions can be granted at any level of these hierarchies, and they flow downwards. So granting permission on a resource higher up the chain automatically grants that same permission on all resources lower down. For example, granting SELECT on a KEYSPACE automatically grants it on all TABLES in that KEYSPACE.

Modifications to permissions are visible to existing client sessions; that is, connections need not be re-established following permissions changes.

The full set of available permissions is:

  • CREATE

  • ALTER

  • DROP

  • SELECT

  • MODIFY

  • AUTHORIZE

  • DESCRIBE

Attempting to GRANT permission on a resource to which it cannot be applied results in an error response. The following illustrates which permissions can be granted on which types of resources, and which statements are enabled by that permission.

Permission

Resource

Operations

CREATE

ALL KEYSPACES

CREATE KEYSPACE and CREATE TABLE in any keyspace

CREATE

KEYSPACE keyspace_name

CREATE TABLE in specified keyspace

ALTER

ALL KEYSPACES

ALTER KEYSPACE and ALTER TABLE in any keyspace

ALTER

KEYSPACE keyspace_name

ALTER KEYSPACE and ALTER TABLE in specified keyspace

ALTER

TABLE table_name

ALTER TABLE on specified table

DROP

ALL KEYSPACES

DROP KEYSPACE and DROP TABLE in any keyspace

DROP

KEYSPACE keyspace_name

DROP TABLE and DROP KEYSPACE in specified keyspace

DROP

TABLE table_name

DROP TABLE

SELECT

ALL KEYSPACES

SELECT on any table

SELECT

KEYSPACE keyspace_name

SELECT on any table in specified keyspace

SELECT

TABLE table_name

SELECT on specified table

MODIFY

ALL KEYSPACES

INSERT, UPDATE, DELETE and TRUNCATE on any table

MODIFY

KEYSPACE keyspace_name

INSERT, UPDATE, DELETE and TRUNCATE on any table in the specified keyspace

MODIFY

TABLE table_name

INSERT, UPDATE, DELETE and TRUNCATE on specified table

AUTHORIZE

ALL KEYSPACES

GRANT PERMISSION and REVOKE PERMISSION on any table

AUTHORIZE

KEYSPACE keyspace_name

GRANT PERMISSION and REVOKE PERMISSION on any table in the specified keyspace

AUTHORIZE

TABLE table_name

GRANT PERMISSION and REVOKE PERMISSION on specified table

DESCRIBE

ALL ROLES

LIST ROLES on all roles or only roles granted to another specified role

GRANT PERMISSION¶

Granting permission uses the GRANT PERMISSION statement:

grant_permission_statement: GRANT `permissions` ON `resource` TO `user_name`
permissions: ALL [ PERMISSIONS ] | `permission` [ PERMISSION ]
permission: CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE | DESCRIBE
resource: ALL KEYSPACES
        :| KEYSPACE `keyspace_name`
        :| [ TABLE ] `table_name`
        :| ALL USERS
        :| USER `user_name`

For instance:

GRANT SELECT ON ALL KEYSPACES TO data_reader;

This gives any user with the data_reader role, permission to execute SELECT statements on any table across all keyspaces:

GRANT MODIFY ON KEYSPACE keyspace1 TO data_writer;

This gives any user with the data_writer role, permission to perform UPDATE, INSERT, DELETE, and TRUNCATE queries on all tables in the keyspace1 keyspace:

GRANT DROP ON keyspace1.table1 TO schema_owner;

This gives any user with the schema_owner role, permissions to DROP keyspace1.table1

GRANT ALL¶

When the GRANT ALL form is used, the appropriate set of permissions is determined automatically based on the target resource.

Automatic Granting¶

When a resource is created, via a CREATE KEYSPACE, CREATE TABLE or CREATE USER statement, the creator (the role the database user who issues the statement is identified as) is automatically granted all applicable permissions on the new resource.

REVOKE PERMISSION¶

Revoking permission from a user uses the REVOKE PERMISSION statement:

revoke_permission_statement: REVOKE `permissions` ON `resource` FROM `user_name`

For instance:

REVOKE SELECT ON ALL KEYSPACES FROM data_reader;
REVOKE MODIFY ON KEYSPACE keyspace1 FROM data_writer;
REVOKE DROP ON keyspace1.table1 FROM schema_owner;
REVOKE DESCRIBE ON ALL USERS FROM user_admin;

LIST PERMISSIONS¶

Listing granted permissions uses the LIST PERMISSIONS statement:

list_permissions_statement: LIST `permissions` [ ON `resource` ] [ OF `user_name` [ NORECURSIVE ] ]

For instance:

LIST ALL PERMISSIONS OF alice;

Show all permissions granted to alice, including those acquired transitively from any other users:

LIST ALL PERMISSIONS ON keyspace1.table1 OF bob;

Show all permissions on keyspace1.table1 granted to bob, including those acquired transitively from any other users. This also includes any permissions higher up the resource hierarchy, which can be applied to keyspace1.table1. For example, should bob have ALTER permission on keyspace1, that would be included in the results of this query. Adding the NORECURSIVE switch restricts the results to only those permissions which were directly granted to bob:

LIST SELECT PERMISSIONS OF carlos;

Show any permissions granted to carlos, limited to SELECT permissions on any resource.

Related Topics¶

  • Apache Cassandra Query Language (CQL) Reference

  • Role Based Access Control (RBAC)

Copyright

© 2016, The Apache Software Foundation.

Apache®, Apache Cassandra®, Cassandra®, the Apache feather logo and the Apache Cassandra® Eye logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.

Was this page helpful?

PREVIOUS
Enable Authorization
NEXT
Role Based Access Control (RBAC)
  • Create an issue
  • Edit this page

On this page

  • Grant Authorization CQL Reference
    • Database Roles
      • CREATE ROLE
        • Setting credentials for internal authentication
        • Creating a role conditionally
      • ALTER ROLE
      • DROP ROLE
      • GRANT ROLE
      • REVOKE ROLE
      • LIST ROLES
    • Users
      • CREATE USER
      • ALTER USER
      • DROP USER
      • LIST USERS
    • Data Control
      • Permissions
      • GRANT PERMISSION
        • GRANT ALL
        • Automatic Granting
      • REVOKE PERMISSION
      • LIST PERMISSIONS
        • Related Topics
ScyllaDB Open Source
  • 5.2
    • master
    • 6.2
    • 6.1
    • 6.0
    • 5.4
    • 5.2
    • 5.1
  • Getting Started
    • Install ScyllaDB
      • ScyllaDB Web Installer for Linux
      • ScyllaDB Unified Installer (relocatable executable)
      • Air-gapped Server Installation
      • What is in each RPM
      • ScyllaDB Housekeeping and how to disable it
      • ScyllaDB Developer Mode
      • ScyllaDB Configuration Reference
    • Configure ScyllaDB
    • ScyllaDB Requirements
      • System Requirements
      • OS Support by Linux Distributions and Version
      • ScyllaDB in a Shared Environment
    • Migrate to ScyllaDB
      • Migration Process from Cassandra to Scylla
      • Scylla and Apache Cassandra Compatibility
      • Migration Tools Overview
    • Integration Solutions
      • Integrate Scylla with Spark
      • Integrate Scylla with KairosDB
      • Integrate Scylla with Presto
      • Integrate Scylla with Elasticsearch
      • Integrate Scylla with Kubernetes
      • Integrate Scylla with the JanusGraph Graph Data System
      • Integrate Scylla with DataDog
      • Integrate Scylla with Kafka
      • Integrate Scylla with IOTA Chronicle
      • Integrate Scylla with Spring
      • Shard-Aware Kafka Connector for Scylla
      • Install Scylla with Ansible
      • Integrate Scylla with Databricks
    • Tutorials
  • ScyllaDB for Administrators
    • Administration Guide
    • Procedures
      • Cluster Management
      • Backup & Restore
      • Change Configuration
      • Maintenance
      • Best Practices
      • Benchmarking Scylla
      • Migrate from Cassandra to Scylla
      • Disable Housekeeping
    • Security
      • ScyllaDB Security Checklist
      • Enable Authentication
      • Enable and Disable Authentication Without Downtime
      • Generate a cqlshrc File
      • Reset Authenticator Password
      • Enable Authorization
      • Grant Authorization CQL Reference
      • Role Based Access Control (RBAC)
      • ScyllaDB Auditing Guide
      • Encryption: Data in Transit Client to Node
      • Encryption: Data in Transit Node to Node
      • Generating a self-signed Certificate Chain Using openssl
      • Encryption at Rest
      • LDAP Authentication
      • LDAP Authorization (Role Management)
    • Admin Tools
      • Nodetool Reference
      • CQLSh
      • REST
      • Tracing
      • Scylla SStable
      • Scylla Types
      • SSTableLoader
      • cassandra-stress
      • SSTabledump
      • SSTable2json
      • Scylla Logs
      • Seastar Perftune
      • Virtual Tables
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
    • ScyllaDB Manager
    • Upgrade Procedures
      • ScyllaDB Open Source Upgrade
      • ScyllaDB Open Source to ScyllaDB Enterprise Upgrade
      • ScyllaDB Image
      • ScyllaDB Enterprise
    • System Configuration
      • System Configuration Guide
      • scylla.yaml
      • ScyllaDB Snitches
    • Benchmarking ScyllaDB
  • ScyllaDB for Developers
    • Learn To Use ScyllaDB
      • Scylla University
      • Course catalog
      • Scylla Essentials
      • Basic Data Modeling
      • Advanced Data Modeling
      • MMS - Learn by Example
      • Care-Pet an IoT Use Case and Example
    • Scylla Alternator
    • Scylla Features
      • Scylla Open Source Features
      • Scylla Enterprise Features
    • Scylla Drivers
      • Scylla CQL Drivers
      • Scylla DynamoDB Drivers
    • Workload Attributes
  • CQL Reference
    • CQLSh: the CQL shell
    • Appendices
    • Compaction
    • Consistency Levels
    • Consistency Level Calculator
    • Data Definition
    • Data Manipulation
    • Data Types
    • Definitions
    • Global Secondary Indexes
    • Additional Information
    • Expiring Data with Time to Live (TTL)
    • Additional Information
    • Functions
    • JSON Support
    • Materialized Views
    • Non-Reserved CQL Keywords
    • Reserved CQL Keywords
    • ScyllaDB CQL Extensions
  • ScyllaDB Architecture
    • ScyllaDB Ring Architecture
    • ScyllaDB Fault Tolerance
    • Consistency Level Console Demo
    • ScyllaDB Anti-Entropy
      • Scylla Hinted Handoff
      • Scylla Read Repair
      • Scylla Repair
    • SSTable
      • ScyllaDB SSTable - 2.x
      • ScyllaDB SSTable - 3.x
    • Compaction Strategies
    • Raft Consensus Algorithm in ScyllaDB
  • Troubleshooting ScyllaDB
    • Errors and Support
      • Report a Scylla problem
      • Error Messages
      • Change Log Level
    • ScyllaDB Startup
      • Ownership Problems
      • Scylla will not Start
      • Scylla Python Script broken
    • Upgrade
      • Inaccessible configuration files after ScyllaDB upgrade
    • Cluster and Node
      • Failed Decommission Problem
      • Cluster Timeouts
      • Node Joined With No Data
      • SocketTimeoutException
      • NullPointerException
    • Data Modeling
      • Scylla Large Partitions Table
      • Scylla Large Rows and Cells Table
      • Large Partitions Hunting
    • Data Storage and SSTables
      • Space Utilization Increasing
      • Disk Space is not Reclaimed
      • SSTable Corruption Problem
      • Pointless Compactions
      • Limiting Compaction
    • CQL
      • Time Range Query Fails
      • COPY FROM Fails
      • CQL Connection Table
      • Reverse queries fail
    • ScyllaDB Monitor and Manager
      • Manager and Monitoring integration
      • Manager lists healthy nodes as down
  • Knowledge Base
    • Upgrading from experimental CDC
    • Compaction
    • Counting all rows in a table is slow
    • CQL Query Does Not Display Entire Result Set
    • When CQLSh query returns partial results with followed by “More”
    • Run Scylla and supporting services as a custom user:group
    • Decoding Stack Traces
    • Snapshots and Disk Utilization
    • DPDK mode
    • Debug your database with Flame Graphs
    • How to Change gc_grace_seconds for a Table
    • Gossip in Scylla
    • Increase Permission Cache to Avoid Non-paged Queries
    • How does Scylla LWT Differ from Apache Cassandra ?
    • Map CPUs to Scylla Shards
    • Scylla Memory Usage
    • NTP Configuration for Scylla
    • Updating the Mode in perftune.yaml After a ScyllaDB Upgrade
    • POSIX networking for Scylla
    • Scylla consistency quiz for administrators
    • Recreate RAID devices
    • How to Safely Increase the Replication Factor
    • Scylla and Spark integration
    • Increase Scylla resource limits over systemd
    • Scylla Seed Nodes
    • How to Set up a Swap Space
    • Scylla Snapshots
    • Scylla payload sent duplicated static columns
    • Stopping a local repair
    • System Limits
    • How to flush old tombstones from a table
    • Time to Live (TTL) and Compaction
    • Scylla Nodes are Unresponsive
    • Update a Primary Key
    • Using the perf utility with Scylla
    • Configure Scylla Networking with Multiple NIC/IP Combinations
  • ScyllaDB FAQ
  • Contribute to ScyllaDB
  • Glossary
  • Alternator: DynamoDB API in Scylla
    • Getting Started With ScyllaDB Alternator
    • ScyllaDB Alternator for DynamoDB users
Docs Tutorials University Contact Us About Us
© 2025, ScyllaDB. All rights reserved. | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 08 May 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.6