Apache Cassandra

How to Enable Authentication in Cassandra Cluster

“Security is an important feature when working with databases. It is good to ensure that your data is secure from unauthorized access and authorized users. In Cassandra, we achieve this by securing your cluster with username, password, and user permissions.

By default, Cassandra’s username and password authentication are disabled. It is, therefore, up to you to enable and configure auth methods for your cluster.

This tutorial aims to show you how you can set up a basic username and password authentication on your Cassandra cluster by editing various config options.”

Let’s dive in.

Step 1 – Configure the Cassandra Authentication Backend

The first step in enabling user authentication for your cluster is defining your authenticator backend

Edit your cassandra.yml file and locate the authenticator entry. Change this value from AllowAuthenticator to PasswordAuthenticator.

# before

authenticator: AllowAuthenticator

# after

authenticator: PasswordAuthenticator

Step 2 – Configure Cassandra Authorization Backend

Next, configure the Cassandra Authorizer backend entry as shown:

# before

authorizer: AllowAllAuthorizer

# after

authorizer: CassandraAuthorizer

Save the changes to the config file and close.

Step 3 – Restart Cassandra

Once you have saved the changes to the config file, restart the cassandra cluster using your default service manager.

Step 4 – Login to Cassandra

Once the server is up and running, login to the cluster using the default username and password.

$ cqlsh -u cassandra -p cassandra

If successful, you should be dropped to the CQL Shell as the cassandra user. This is a superuser account for administration purposes.

Creating a new user account with standard privileges is recommended when executing non-admin commands to the server.

Check out our tutorial on creating Cassandra users and roles to discover more.

Final Thoughts

Once you have configured your username and passwords, you can modify other settings related to Cassandra security, such as role validity, user permissions, network authorization and more. Check the docs to discover more.

Thanks for reading & see you in the next one.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list