Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Apache Cassandra

You're reading from   Learning Apache Cassandra Build an efficient, scalable, fault-tolerant, and highly-available data layer into your application using Cassandra

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781783989201
Length 246 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
 Brown Brown
Author Profile Icon Brown
Brown
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Learning Apache Cassandra
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Up and Running with Cassandra FREE CHAPTER 2. The First Table 3. Organizing Related Data 4. Beyond Key-Value Lookup 5. Establishing Relationships 6. Denormalizing Data for Maximum Performance 7. Expanding Your Data Model 8. Collections, Tuples, and User-defined Types 9. Aggregating Time-Series Data 10. How Cassandra Distributes Data Peeking Under the Hood Authentication and Authorization Index

Enabling authentication and authorization


By default, Cassandra does not require user authentication when clients connect to the cluster, and it also does not place any restriction on the ability of clients to perform operations on the database. To change this, we will need to make a couple of minor modifications to our Cassandra instance's configuration file. Since modifications to the configuration file are typically a concern of deployment engineers, we haven't interacted with it in this book, so you may be wondering where to find it. Where it's located depends on your platform; the table below assumes you installed Cassandra using the instructions for your platform in the Installing Cassandra section of Chapter 1, Getting Up and Running with Cassandra. The following table gives you the location of the cassandra.yaml file on the respective platforms.

Platform

Configuration file location

Mac OS X

/usr/local/etc/cassandra/cassandra.yaml

Ubuntu

/etc/cassandra/cassandra.yaml

Windows

C:\Program Files\DataStax Community\apache-cassandra\conf\cassandra.yaml

You will need to make two changes to the cassandra.yaml file. First, find the line that begins with authenticator: and change it to:

authenticator: PasswordAuthenticator

This change tells Cassandra to require a username and password when clients connect to the cluster. It does not, however, restrict access based on which user is logged in; to do that, we'll need to enable authorization. Find the line beginning with authorizer: and change it to:

authorizer: CassandraAuthorizer

Now our cluster will restrict the access of the logged in user based on the permissions that user has been granted. You will need to restart your Cassandra instance for the settings to take effect.

Authentication, authorization, and fault tolerance

Using the PasswordAuthenticator and CassandraAuthorizer strategies for authentication and authorization respectively, user credentials and granted permissions are stored in Cassandra itself. This means that, if the authentication data becomes unavailable, no clients will be able to access the cluster. For that reason, you will always want to set the replication factor for your system_auth keyspace to the total number of nodes in your cluster. Since our development cluster consists of only a single node, we don't need to make any changes; in production, however, you will almost certainly have many nodes in your cluster, and you'll want to make sure credentials and permissions are stored locally on every one of them.

Note

For further information on configuring Cassandra authentication, including best practices when configuring authentication in a production cluster, see the DataStax Cassandra documentation at http://www.datastax.com/documentation/cassandra/2.1/cassandra/security/security_config_native_authenticate_t.html.

For more information on configuring authorization, see http://www.datastax.com/documentation/cassandra/2.1/cassandra/security/secure_config_native_authorize_t.html.

Authentication with cqlsh

Now that we've enabled authentication on our development cluster, we will need to reconnect our cqlsh session with a username and password. By default, Cassandra has a superuser account whose username and password are both cassandra, so we can use that:

$ cqlsh -u cassandra -p cassandra

In a production cluster, of course, we would not want to have a superuser account with such an easily guessable password; however, for our purposes, this will work fine.

Authentication in your application

The details differ from language to language, but the CQL driver for your platform should provide a mechanism for authenticated connections. Consult your driver's documentation for more information.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images