Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 May NoSQL: Cassandra introduces Role Based Authentication

NoSQL: Cassandra introduces Role Based Authentication

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

Prior to Cassandra 2.2, it supports only User base authentication, but now Cassandra introduces new Role-based authentication.

In this post, I am sharing a demonstration on how to create a Role in Cassandra and How to assign different permissions to that role.
You can directly use this Role for authentication and you can also assign same Role permission to another role.

First, login with Cassandra’s super user.

1
cqlsh -u cassanddra -p cassandra

Create keyspace if not exists:

1
2
3
CREATE KEYSPACE IF NOT EXISTS dbrnd WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
 
USE dbrnd;

Create few sample tables:

1
2
3
4
5
6
7
8
9
10
11
12
13
CREATE TABLE IF NOT EXISTS tbl_Employee
(
EmpID INT PRIMARY KEY
,EmpFirstName VARCHAR
,EmpLastName VARCHAR
,EmpSalary INT
);
 
CREATE TABLE IF NOT EXISTS tbl_Department
(
DeptID INT PRIMARY KEY
,DeptName VARCHAR
);

Create one sample Role without Superuser access:
If you get this error : “org.apache.cassandra.auth.CassandraRoleManager doesn’t support PASSWORD”, visit this solution.

1
CREATE ROLE ReportingRole WITH PASSWORD = 'pass123' AND LOGIN = true AND SUPERUSER = false;

Grant different permissions to this Role:

1
2
GRANT SELECT ON dbrnd.tbl_Employee TO ReportingRole;
GRANT MODIFY ON dbrnd.tbl_Department TO ReportingRole;

If you get any error like ” GRANT operation is not supported by AllowAllAuthorizer”, you have to modify the value of “authorizer” in cassandra.yaml file.

1
2
3
4
5
-- Old value:
authorizer: AllowAllAuthorizer
-- Change to this New value:
authorizer: org.apache.cassandra.auth.CassandraAuthorizer

Grant over the all keyspaces:

1
2
GRANT SELECT ON ALL KEYSPACES TO ReportingRole;
GRANT MODIFY ON ALL KEYSPACES TO ReportingRole;

Create new test Role and make it a replica of the current role:

1
2
3
CREATE ROLE Test WITH PASSWORD = 'pass123' AND LOGIN = true AND SUPERUSER = false;
 
GRANT ReportingRole to Test;

List out all Roles and its permissions:

1
2
3
4
-- List out all Roles.
LIST ROLES;
-- List out all permissions of the Role.
LIST ALL PERMISSIONS OF ReportingRole;

Cassandra User Role

May 8, 2016Anvesh Patel
NoSQL: "org.apache.cassandra.auth.CassandraRoleManager doesn't support PASSWORD"NoSQL: Cassandra default list of port usage
Comments: 3
  1. Deepesh
    August 4, 2017 at 10:49 am

    Hey Nice Article,
    Just an update,
    instead of this (authorizer: org.apache.cassandra.auth.CassandraAuthorizer)
    authorizer: CassandraAuthorizer

    will also work.

  2. John
    November 15, 2017 at 9:42 pm

    Many thanks, Numerous posts.

  3. Prabhakar
    March 18, 2018 at 12:09 pm

    Many thanks. It solved my problem.

Anvesh Patel
Anvesh Patel

Database Engineer

May 8, 2016 Cassandra, NoSQLAnvesh Patel, Cassandra, Column Store, database, database research and development, dbrnd, Document Store, GRANT, Graph Store, Key Value Store, NoSQL, Not Only SQL, role, Unstrucutred
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....