Cassandra Network Authorization
Cassandra provides network-level authorization to restrict client access based on datacenter location or IP address ranges.
Overview
Section titled “Overview”| Feature | Version | Purpose |
|---|---|---|
network_authorizer | Cassandra 4.0+ | Restrict role access to specific datacenters |
cidr_authorizer | Cassandra 5.0+ | Restrict role access based on client IP ranges |
Datacenter Authorization (Cassandra 4.0+)
Section titled “Datacenter Authorization (Cassandra 4.0+)”The network_authorizer setting controls which datacenters a role can access. This feature restricts client connections to specific datacenters within a cluster.
Configuration
Section titled “Configuration”# Options:# - AllowAllNetworkAuthorizer: No restrictions (default)# - CassandraNetworkAuthorizer: Datacenter-based restrictionsnetwork_authorizer: class_name: CassandraNetworkAuthorizerConfiguration Format
In Cassandra 4.0+, network_authorizer uses a ParameterizedClass format with class_name and optional parameters block, not a simple string value.
Requirements:
authenticatormust be set toPasswordAuthenticator- Increase
system_authkeyspace replication factor for high availability
Granting Datacenter Access
Section titled “Granting Datacenter Access”-- Grant access to all datacentersCREATE ROLE app_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS TO ALL DATACENTERS;
-- Restrict to specific datacentersCREATE ROLE dc1_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS TO DATACENTERS {'dc1'};
-- Multiple datacentersCREATE ROLE multi_dc_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS TO DATACENTERS {'dc1', 'dc2'};Modifying Datacenter Access
Section titled “Modifying Datacenter Access”-- Grant access to additional datacentersALTER ROLE app_user WITH ACCESS TO DATACENTERS {'dc1', 'dc2', 'dc3'};
-- Grant access to all datacentersALTER ROLE app_user WITH ACCESS TO ALL DATACENTERS;Default Behavior
Section titled “Default Behavior”Omitting the datacenter clause from CREATE ROLE grants access to all datacenters by default.
CIDR Authorization (Cassandra 5.0+)
Section titled “CIDR Authorization (Cassandra 5.0+)”The cidr_authorizer setting restricts database access based on client IP address ranges defined using CIDR notation. This feature prevents unauthorized access from unexpected network locations.
Configuration
Section titled “Configuration”# Options:# - AllowAllCIDRAuthorizer: No restrictions (default)# - CassandraCIDRAuthorizer: CIDR-based restrictionscidr_authorizer: class_name: CassandraCIDRAuthorizer parameters: # Enable CIDR checks for superusers (default: false) cidr_checks_for_superusers: false # Authorizer mode: # - MONITOR: Log violations without enforcement # - ENFORCE: Reject unauthorized access cidr_authorizer_mode: MONITOR # Cache settings cidr_groups_cache_refresh_interval: 5 ip_cache_max_size: 100Configuration Format
In Cassandra 5.0+, CIDR authorizer settings (cidr_checks_for_superusers, cidr_authorizer_mode, cidr_groups_cache_refresh_interval, ip_cache_max_size) are placed under cidr_authorizer.parameters, not as top-level keys.
Requirements:
authenticatormust be set toPasswordAuthenticator- Increase
system_authkeyspace replication factor for high availability - CIDR checks do not apply to JMX connections
Authorizer Modes
Section titled “Authorizer Modes”| Mode | Behavior |
|---|---|
MONITOR | Log unauthorized access attempts without blocking (default) |
ENFORCE | Reject connections from unauthorized CIDR groups |
The MONITOR mode allows validation of CIDR rules before enforcement.
Managing CIDR Groups
Section titled “Managing CIDR Groups”CIDR groups are stored in the system_auth.cidr_groups table.
-- View existing CIDR groupsSELECT * FROM system_auth.cidr_groups;Use nodetool to manage CIDR groups:
# List available CIDR groupsnodetool listcidrgroups
# Reload CIDR groups cachenodetool reloadcidrgroupscache
# Get CIDR groups for an IP addressnodetool getcidrgroupsofip 192.168.1.100
# View CIDR filtering statisticsnodetool cidrfilteringstatsGranting CIDR Access
Section titled “Granting CIDR Access”-- Grant access from specific CIDR groupsCREATE ROLE regional_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS FROM CIDRS {'region1', 'region2'};
-- Grant access from all CIDR groupsCREATE ROLE global_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS FROM ALL CIDRS;Modifying CIDR Access
Section titled “Modifying CIDR Access”-- Update CIDR accessALTER ROLE regional_user WITH ACCESS FROM CIDRS {'region1'};
-- Grant access from all CIDR groupsALTER ROLE regional_user WITH ACCESS FROM ALL CIDRS;Default Behavior
Section titled “Default Behavior”Omitting the CIDR clause from CREATE ROLE grants access from all CIDR groups by default.
Combining Network Authorizers
Section titled “Combining Network Authorizers”Datacenter authorization and CIDR authorization can be used together for defense in depth.
-- Restrict by both datacenter and CIDRCREATE ROLE restricted_user WITH PASSWORD = 'password' AND LOGIN = true AND ACCESS TO DATACENTERS {'dc1'} AND ACCESS FROM CIDRS {'office_network'};System Tables
Section titled “System Tables”| Table | Purpose |
|---|---|
system_auth.network_permissions | Datacenter access permissions |
system_auth.cidr_groups | CIDR group definitions |
system_auth.cidr_permissions | CIDR access permissions |
Best Practices
Section titled “Best Practices”- Test in MONITOR mode: Validate CIDR rules before switching to ENFORCE mode
- Increase replication: Set
system_authkeyspace replication factor to match cluster size - Plan for failover: Ensure roles have access to disaster recovery datacenters
- Document CIDR groups: Maintain clear documentation of IP ranges per group
- Regular audits: Review network permissions periodically
Next Steps
Section titled “Next Steps”- Authentication - User authentication
- Authorization - Role-based access control
- Encryption - SSL/TLS configuration
- Security Overview - Security guide