Role Management
Master roles, permissions, and user access control!
๐ The Story: Sarah's Intern DELETE Disaster
Sarah hired a summer intern to help with data analytics. Gave the intern the SAME superuser account she used. No role management. No permission restrictions. Day 3: Intern runs DELETE query on production table to "clean up test data." Deleted 2 MILLION customer records. GONE. No backups (another mistake). $5M in lost data. Lawsuits. Sarah fired. All because intern had DELETE permission.
๐ฑ The Accidental DELETE
Monday - Intern's First Week:
- ๐จโ๐ผ Sarah creates account: intern@company.com
- ๐ฅ Gives superuser role (FULL access!)
- ๐ Intern told to "analyze customer data"
- ๐คท No training on production vs dev
- ๐ No restrictions - can do ANYTHING
Wednesday 2:00 PM - The Fatal Query:
Wednesday 2:05 PM - The Discovery:
- ๐ Customer service: "Customers disappeared!"
- ๐ฑ Team checks database: 2M records GONE
- ๐ Audit logs show: intern@company.com
- ๐ Check backups: NONE (budget cuts)
- ๐ญ Data is PERMANENTLY LOST
The Damage:
- ๐ฐ $5M: Lost customer data value
- โ๏ธ $2M: Lawsuits from customers
- ๐ก 2 million: Angry customers
- ๐ 30%: Revenue drop
- ๐ผ Sarah: Fired
- ๐จโ๐ผ Intern: Fired (poor kid!)
- ๐ข Company: Reputation destroyed
โ With Proper Role Management
What Should Have Happened:
The Better Outcome:
- โ $0: No data loss
- โ 0 customers: Affected
- โ Intern: Learns from blocked query
- โ Sarah: Keeps job, promoted for good security
- โ Company: Business continues normally
- โ Lesson: Intern gets proper training
Proper roles: The difference between $7M loss and $0! ๐ฏ
๐ฅ What Are Roles in Cassandra?
Understand the fundamentals!
Definition
Roles are identities in Cassandra that can:
- Login: Connect to the database
- Own permissions: Have specific access rights
- Be granted to others: Create role hierarchies
- Inherit permissions: From parent roles
Two types of roles:
- Login roles: Users that can connect (WITH LOGIN = true)
- Non-login roles: Groups for permission management (WITH LOGIN = false)
Roles vs Traditional Users
Old Way: Users
Cassandra 2.x and earlier
- Users and permissions separate
- No role hierarchies
- Permissions per user only
- Hard to manage at scale
- Deprecated in 3.0+
New Way: Roles
Cassandra 3.0+ (current)
- Unified identity system
- Role hierarchies supported
- Permission inheritance
- Scalable management
- Industry standard (RBAC)
Role-Based Access Control (RBAC)
The RBAC Model
Instead of assigning permissions directly to users:
- Create roles: Define job functions (admin, developer, analyst)
- Assign permissions to roles: What each role can do
- Grant roles to users: Users inherit role permissions
- Change once, apply everywhere: Update role, all users affected
Result: Easier management, fewer mistakes, better security! โ
โ Creating and Managing Roles
Complete guide!
Create Basic Role
Modify Existing Role
Delete Role
List and View Roles
๐ Managing Permissions
Control what roles can do!
Available Permissions
| Permission | Description | Example |
|---|---|---|
| CREATE | Create keyspaces or tables | CREATE KEYSPACE, CREATE TABLE |
| ALTER | Modify keyspaces or tables | ALTER TABLE, ALTER KEYSPACE |
| DROP | Delete keyspaces or tables | DROP TABLE, DROP KEYSPACE |
| SELECT | Read data | SELECT * FROM table |
| MODIFY | Write data (INSERT/UPDATE/DELETE) | INSERT, UPDATE, DELETE |
| AUTHORIZE | Grant/revoke permissions | GRANT SELECT TO role |
| DESCRIBE | View schema metadata | DESCRIBE TABLE |
| EXECUTE | Use functions | Call UDF/UDA |
Granting Permissions
Keyspace-Level Permissions
Table-Level Permissions
All Tables/Keyspaces
Role Management Permissions
Revoking Permissions
Viewing Permissions
๐ Role Hierarchy & Inheritance
Organize roles efficiently!
How Inheritance Works
Roles can be granted to other roles, creating hierarchies:
- โ Child role inherits: All permissions from parent roles
- โ Multiple inheritance: Role can have multiple parents
- โ Transitive: Grandchild inherits from grandparent
- โ Efficient: Change parent, affects all children
Example Hierarchy
Role Hierarchy Diagram
โโโโโโโโโโโโโโโโ
โ Superuser โ
โโโโโโโโฌโโโโโโโโ
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ โโโโโโผโโโโโ
โ DBAs โ โ Devs โ โ Analystsโ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโฌโโโโโ
โ โ โ
Charlie Bob Alice
โ โ โ
(All permissions) (Read/Write (Read-only
+ Schema) access)
๐ก Role Management Best Practices
Do it right!
DO
- Use principle of least privilege
- Create role hierarchies
- Use descriptive role names
- Document role purposes
- Regular access reviews
- Disable unused accounts
- Use non-login roles for groups
- Test permissions before granting
DON'T
- Give everyone superuser
- Share login credentials
- Grant permissions directly to users
- Use default cassandra account
- Forget to revoke on departure
- Mix dev and prod access
- Grant more than needed
- Skip audit logging
Principle of Least Privilege
Grant Minimum Necessary Access
Always ask: What's the MINIMUM permission needed?
| Role | โ Too Much | โ Just Right |
|---|---|---|
| Analyst | MODIFY (can change data) | SELECT only (read-only) |
| App | ALL PERMISSIONS | SELECT + MODIFY on specific tables |
| Developer | SUPERUSER | CREATE, ALTER on dev keyspace only |
| Intern | MODIFY (Sarah's mistake!) | SELECT only + supervised |
Naming Conventions
Access Review Process
Quarterly Review
- List all roles and permissions
- Review with team leads
- Verify users still need access
- Remove departed employees
- Revoke unused permissions
Onboarding Process
- Create account with descriptive name
- Grant appropriate role (not superuser!)
- Document reason for access
- Set expiration for temporary access
- Provide security training
Offboarding Process
๐ฏ Common Role Patterns
Real-world examples!
Application Roles
Service accounts for applications
Read-Only Analyst Role
For data analysts and BI tools
Developer Role (Non-Production)
For developers in dev/staging
DBA Role
For database administrators
Monitoring Role
For monitoring tools (Prometheus, Grafana)
๐ Master Role Management!
You now know how to implement proper access control!
๐ What You Learned:
- ๐ Sarah's disaster: $7M loss from giving intern DELETE access
- ๐ฅ What are roles: RBAC model for access control
- โ Creating roles: CREATE, ALTER, DROP, LIST commands
- ๐ Permissions: GRANT/REVOKE 8 permission types
- ๐ Hierarchies: Role inheritance and organization
- ๐ก Best practices: Least privilege, naming, reviews
- ๐ฏ Common patterns: 5 real-world role examples
๐ก Key Takeaways:
- Least privilege - Grant only minimum needed access
- Use role hierarchies - Organize with parent/child roles
- Never share credentials - Individual accounts for everyone
- Regular reviews - Quarterly access audits
- Document everything - Why each role exists
- Test before granting - Verify permissions work correctly
๐ Quick Setup (Read-Only Role):
๐ฏ 8 Permission Types:
- CREATE: Make keyspaces/tables
- ALTER: Modify schema
- DROP: Delete objects
- SELECT: Read data
- MODIFY: Insert/Update/Delete
- AUTHORIZE: Grant permissions
- DESCRIBE: View schema
- EXECUTE: Use functions
โ ๏ธ Sarah's Lesson:
| Scenario | โ Without Roles | โ With Roles |
|---|---|---|
| Intern Access | DELETE permission | SELECT only |
| Result | 2M records deleted | DELETE blocked |
| Cost | $7M loss | $0 loss |
| Sarah | Fired | Promoted |
๐ฅ Remember Sarah: Proper roles = $7M saved! ๐ฏ
Implement RBAC NOW!
Responsive Ad