How to configure access permissions for Cassandra on Linux Ubuntu
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Apache Cassandra is a high-performance NoSQL database known for its scalability and fault tolerance. When deploying Cassandra in a production environment, managing access permissions is critical for maintaining data security and integrity. This guide will walk you through configuring access permissions for Cassandra on Linux Ubuntu, ensuring that only authorized users can access and manipulate data.
Prerequisites
Before configuring access permissions, ensure that you have:
- A Linux Ubuntu server with Cassandra installed.
- Access to a terminal or SSH client to connect to your server.
- Root or administrator privileges to modify system configurations.
- Basic understanding of Cassandra architecture and CQL (Cassandra Query Language).
Configure Cassandra Authentication
By default, Cassandra does not enforce authentication. We will enable it to restrict database access only to authenticated users.
- Edit the
cassandra.yamlfile:Locate the Cassandra configuration file, typically found at/etc/cassandra/cassandra.yaml.
- Set up Authentication:In the
cassandra.yamlfile, find theauthenticatorproperty and set it toPasswordAuthenticator.
- Set up Authorizer:Set the
authorizerproperty toCassandraAuthorizerto enable authorization.
- Restart Cassandra:Save your changes and restart the Cassandra service to apply the new authentication settings.
Create a Superuser
After enabling authentication, the next step is to create a superuser account to manage database permissions.
- Connect to Cassandra:Use
cqlsh, the Cassandra command-line shell, to connect to your database.
- Create a Superuser Account:Run the following CQL command to create a new superuser:
Replace 'admin_password' with a strong, secure password.
- Exit
cqlsh:
Manage User Roles and Permissions
With a superuser account in place, you can now create users and assign appropriate permissions based on their roles.
- Log in as Superuser:Reconnect to Cassandra using the new superuser account.
- Create New Roles:To create a regular user, use the following command:
This role does not have superuser privileges, limiting access to specific keyspaces or operations you define.
- Grant Permissions:Assign permissions using the
GRANTstatement. For example, to grant read/write access to a specific keyspace:
Replace my_keyspace with the actual name of the keyspace.
- Revoke Permissions:If you need to revoke permissions, use the
REVOKEstatement:
- List Role Permissions:To view permissions granted to a user:
Security Best Practices
- Use Strong Passwords: Ensure all users, especially superusers, have complex and unique passwords.
- Least Privilege Principle: Only grant the minimum necessary permissions to users, reducing the risk of unauthorized access.
- Regular Audits: Periodically review user roles and permissions, revoking access that is no longer needed.
- Monitor Logs: Enable and monitor audit logs to track security-related events and detect potential threats early.
Summary Table
Here's a quick reference table for configuring access permissions:
| Task | Command/Action |
| Enable Authentication | Set authenticator: PasswordAuthenticator and authorizer: CassandraAuthorizer in cassandra.yaml. |
| Restart Service | sudo systemctl restart cassandra |
| Create Superuser | CREATE ROLE admin WITH PASSWORD = 'admin_password' AND SUPERUSER = true AND LOGIN = true; |
| Create User Role | CREATE ROLE data_user WITH PASSWORD = 'user_password' AND LOGIN = true; |
| Grant Permissions | GRANT MODIFY ON KEYSPACE my_keyspace TO data_user;
GRANT SELECT ON KEYSPACE my_keyspace TO data_user; |
| Revoke Permissions | REVOKE MODIFY ON KEYSPACE my_keyspace FROM data_user; |
| List Permissions | LIST ALL PERMISSIONS OF data_user; |
Conclusion
Configuring access permissions in Cassandra is vital for securing your database against unauthorized access. By enabling authentication, creating user roles, and granting specific permissions, you can maintain data integrity and security, aligning with best practices for operating a production database. Regularly reviewing and updating access policies further strengthens your database's defense against potential threats.
Related reading
- how to configure redis ttl with spring boot 2.0
- How to configure spring-boot to use file based H2 database
- How to configure spring-data-mongodb to use a replica set via properties
- How to configure spring boot application to use aspectj transactions?
- How to configure CORS in a Spring Boot Spring Security application?
- how to configure ingress to direct traffic to an https backend using https
- how to configure the DBeaver and Cassandra
- How to configure the slow query log in TiDB?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.