Cassandra Authentication
Authentication controls which clients can connect to the cluster. By default, Cassandra allows all connections without credentials.
Built-in Authenticators
Section titled “Built-in Authenticators”Cassandra provides the following authenticator implementations:
| Authenticator | Description | Use Case |
|---|---|---|
AllowAllAuthenticator | No authentication (default) | Development, testing |
PasswordAuthenticator | Username/password authentication | Production environments |
MutualTlsAuthenticator | Certificate-based authentication (5.0+) | Zero-trust environments |
MutualTlsWithPasswordFallbackAuthenticator | Certificates with password fallback (5.0+) | Migration to mTLS |
AllowAllAuthenticator (Default)
Section titled “AllowAllAuthenticator (Default)”The default configuration performs no authentication. Any client can connect without credentials.
# cassandra.yaml (default)authenticator: AllowAllAuthenticatorProduction Warning
AllowAllAuthenticator must not be used in production. Any client with network access can read, modify, or delete all data.
PasswordAuthenticator
Section titled “PasswordAuthenticator”Requires username and password credentials. Credentials are stored in the system_auth.roles table.
authenticator: PasswordAuthenticatorMutualTlsAuthenticator (Cassandra 5.0+)
Section titled “MutualTlsAuthenticator (Cassandra 5.0+)”Authenticates clients using X.509 certificates. Requires client encryption with mandatory certificate verification. See Mutual TLS Authentication for configuration details.
Enabling Password Authentication
Section titled “Enabling Password Authentication”authenticator: PasswordAuthenticatorAfter enabling, restart all nodes in a rolling manner.
Default Credentials
Section titled “Default Credentials”Username: cassandraPassword: cassandraImportant: Change immediately after enabling authentication.
Creating Users
Section titled “Creating Users”-- Connect with default credentialscqlsh -u cassandra -p cassandra
-- Create new superuserCREATE ROLE admin WITH PASSWORD = 'strong_password' AND SUPERUSER = true AND LOGIN = true;
-- Disable default superuserALTER ROLE cassandra WITH SUPERUSER = false AND LOGIN = false;
-- Create application userCREATE ROLE app_user WITH PASSWORD = 'app_password' AND LOGIN = true;Role Management
Section titled “Role Management”-- List rolesLIST ROLES;
-- Create role without loginCREATE ROLE readonly_role;
-- Grant role to userGRANT readonly_role TO app_user;
-- Revoke roleREVOKE readonly_role FROM app_user;
-- Drop roleDROP ROLE IF EXISTS old_role;Authentication Cache
Section titled “Authentication Cache”credentials_validity_in_ms: 2000credentials_update_interval_in_ms: 2000credentials_cache_max_entries: 1000Mutual TLS Authentication
Section titled “Mutual TLS Authentication”MutualTlsAuthenticator performs certificate-based authentication for client connections by extracting identities from client certificates and verifying them against authorized identities in the system_auth.identity_to_role table.
Prerequisites
Section titled “Prerequisites”Mutual TLS authentication requires client encryption with mandatory client certificate verification:
client_encryption_options: enabled: true require_client_auth: true keystore: /path/to/keystore.jks keystore_password: keystorepass truststore: /path/to/truststore.jks truststore_password: truststorepassConfiguration
Section titled “Configuration”authenticator: class_name: org.apache.cassandra.auth.MutualTlsAuthenticator parameters: validator_class_name: org.apache.cassandra.auth.SpiffeCertificateValidatorThe validator_class_name parameter specifies the certificate validator implementation. Cassandra includes SpiffeCertificateValidator for SPIFFE-based identity extraction.
SPIFFE Certificate Validator
Section titled “SPIFFE Certificate Validator”The SpiffeCertificateValidator extracts SPIFFE identities from the Subject Alternative Name (SAN) extension of client certificates. SPIFFE identities are URIs in the format spiffe://trust-domain/path.
The validator:
- Examines the SAN extension of the client certificate
- Searches for URI entries beginning with
spiffe:// - Returns the SPIFFE URI as the client identity
Identity Management
Section titled “Identity Management”Identities extracted from certificates must be mapped to roles using the ADD IDENTITY statement:
-- Create role for the applicationCREATE ROLE app_service WITH LOGIN = true;
-- Map certificate identity to roleADD IDENTITY 'spiffe://testdomain.com/testIdentifier/testValue' TO ROLE 'app_service';
-- Use IF NOT EXISTS to avoid errors when identity already existsADD IDENTITY IF NOT EXISTS 'spiffe://testdomain.com/testIdentifier/testValue' TO ROLE 'app_service';
-- Grant permissions to the roleGRANT SELECT ON KEYSPACE myapp TO app_service;To remove an identity mapping:
DROP IDENTITY 'spiffe://testdomain.com/testIdentifier/testValue';
-- Use IF EXISTS to avoid errors if identity does not existDROP IDENTITY IF EXISTS 'spiffe://testdomain.com/testIdentifier/testValue';Note
Only superusers or users with appropriate role management privileges can add or drop identities.
Password Fallback Authenticator
Section titled “Password Fallback Authenticator”For gradual migration from password-based to certificate-based authentication, use MutualTlsWithPasswordFallbackAuthenticator:
authenticator: class_name: org.apache.cassandra.auth.MutualTlsWithPasswordFallbackAuthenticator parameters: validator_class_name: org.apache.cassandra.auth.SpiffeCertificateValidatorThis authenticator accepts both certificate-based and username/password authentication, allowing clients to migrate incrementally.
Custom Certificate Validators
Section titled “Custom Certificate Validators”Custom validators can be implemented by creating a class that implements the MutualTlsCertificateValidator interface:
public interface MutualTlsCertificateValidator { void init(Map<String, String> parameters); String identity(Certificate[] certificateChain) throws CertificateException; boolean isValidCertificate(Certificate[] certificateChain);}Client Configuration
Section titled “Client Configuration”# Command linecqlsh -u username -p password host
# Or use cqlshrc# ~/.cassandra/cqlshrc[authentication]username = usernamepassword = passwordJava Driver
Section titled “Java Driver”CqlSession session = CqlSession.builder() .addContactPoint(new InetSocketAddress("host", 9042)) .withAuthCredentials("username", "password") .build();Python Driver
Section titled “Python Driver”from cassandra.cluster import Clusterfrom cassandra.auth import PlainTextAuthProvider
auth = PlainTextAuthProvider('username', 'password')cluster = Cluster(['host'], auth_provider=auth)session = cluster.connect()Next Steps
Section titled “Next Steps”- Authorization - Permission management
- Encryption - SSL/TLS setup
- Security Overview - Security guide