Search in sources :

Example 1 with IRoleManager

use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.

the class CQLTester method requireAuthentication.

protected static void requireAuthentication() {
    DatabaseDescriptor.setAuthenticator(new AuthTestUtils.LocalPasswordAuthenticator());
    DatabaseDescriptor.setAuthorizer(new AuthTestUtils.LocalCassandraAuthorizer());
    DatabaseDescriptor.setNetworkAuthorizer(new AuthTestUtils.LocalCassandraNetworkAuthorizer());
    // The CassandraRoleManager constructor set the supported and alterable options based on
    // DatabaseDescriptor authenticator type so it needs to be created only after the authenticator is set.
    IRoleManager roleManager = new AuthTestUtils.LocalCassandraRoleManager() {

        public void setup() {
            loadRoleStatement();
            QueryProcessor.executeInternal(createDefaultRoleQuery());
        }
    };
    DatabaseDescriptor.setRoleManager(roleManager);
    MigrationManager.announceNewKeyspace(AuthKeyspace.metadata(), true);
    DatabaseDescriptor.getRoleManager().setup();
    DatabaseDescriptor.getAuthenticator().setup();
    DatabaseDescriptor.getAuthorizer().setup();
    DatabaseDescriptor.getNetworkAuthorizer().setup();
    Schema.instance.registerListener(new AuthSchemaChangeListener());
    AuthCacheService.initializeAndRegisterCaches();
}
Also used : AuthSchemaChangeListener(org.apache.cassandra.auth.AuthSchemaChangeListener) IRoleManager(org.apache.cassandra.auth.IRoleManager) AuthTestUtils(org.apache.cassandra.auth.AuthTestUtils)

Example 2 with IRoleManager

use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.

the class InvalidateJmxPermissionsCacheTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CQLTester.setUpClass();
    CQLTester.requireAuthentication();
    IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
    JMXResource rootJmxResource = JMXResource.root();
    Set<Permission> jmxPermissions = rootJmxResource.applicablePermissions();
    IAuthorizer authorizer = DatabaseDescriptor.getAuthorizer();
    authorizer.grant(AuthenticatedUser.SYSTEM_USER, jmxPermissions, rootJmxResource, ROLE_A);
    authorizer.grant(AuthenticatedUser.SYSTEM_USER, jmxPermissions, rootJmxResource, ROLE_B);
    AuthCacheService.initializeAndRegisterCaches();
    startJMXServer();
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) IAuthorizer(org.apache.cassandra.auth.IAuthorizer) Permission(org.apache.cassandra.auth.Permission) JMXResource(org.apache.cassandra.auth.JMXResource) BeforeClass(org.junit.BeforeClass)

Example 3 with IRoleManager

use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.

the class InvalidateCredentialsCacheTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CQLTester.setUpClass();
    CQLTester.requireAuthentication();
    IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
    PasswordAuthenticator passwordAuthenticator = (PasswordAuthenticator) DatabaseDescriptor.getAuthenticator();
    roleANegotiator = passwordAuthenticator.newSaslNegotiator(null);
    roleANegotiator.evaluateResponse(new PlainTextAuthProvider(ROLE_A.getRoleName(), "ignored").newAuthenticator((EndPoint) null, null).initialResponse());
    roleBNegotiator = passwordAuthenticator.newSaslNegotiator(null);
    roleBNegotiator.evaluateResponse(new PlainTextAuthProvider(ROLE_B.getRoleName(), "ignored").newAuthenticator((EndPoint) null, null).initialResponse());
    startJMXServer();
}
Also used : PasswordAuthenticator(org.apache.cassandra.auth.PasswordAuthenticator) IRoleManager(org.apache.cassandra.auth.IRoleManager) PlainTextAuthProvider(com.datastax.driver.core.PlainTextAuthProvider) BeforeClass(org.junit.BeforeClass)

Example 4 with IRoleManager

use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.

the class RolesCacheKeysTableTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // high value is used for convenient debugging
    DatabaseDescriptor.setRolesValidity(20_000);
    CQLTester.setUpClass();
    CQLTester.requireAuthentication();
    IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_C, AuthTestUtils.getLoginRoleOptions());
    AuthTestUtils.grantRolesTo(roleManager, ROLE_A, ROLE_C);
    AuthTestUtils.grantRolesTo(roleManager, ROLE_B, ROLE_C);
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) BeforeClass(org.junit.BeforeClass)

Example 5 with IRoleManager

use of org.apache.cassandra.auth.IRoleManager in project cassandra by apache.

the class CredentialsCacheKeysTableTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // high value is used for convenient debugging
    DatabaseDescriptor.setCredentialsValidity(20_000);
    CQLTester.setUpClass();
    CQLTester.requireAuthentication();
    passwordAuthenticator = (AuthTestUtils.LocalPasswordAuthenticator) DatabaseDescriptor.getAuthenticator();
    IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_A, AuthTestUtils.getLoginRoleOptions());
    roleManager.createRole(AuthenticatedUser.SYSTEM_USER, ROLE_B, AuthTestUtils.getLoginRoleOptions());
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) AuthTestUtils(org.apache.cassandra.auth.AuthTestUtils) BeforeClass(org.junit.BeforeClass)

Aggregations

IRoleManager (org.apache.cassandra.auth.IRoleManager)11 BeforeClass (org.junit.BeforeClass)10 IAuthorizer (org.apache.cassandra.auth.IAuthorizer)4 Permission (org.apache.cassandra.auth.Permission)4 IResource (org.apache.cassandra.auth.IResource)3 AuthTestUtils (org.apache.cassandra.auth.AuthTestUtils)2 PlainTextAuthProvider (com.datastax.driver.core.PlainTextAuthProvider)1 AuthSchemaChangeListener (org.apache.cassandra.auth.AuthSchemaChangeListener)1 INetworkAuthorizer (org.apache.cassandra.auth.INetworkAuthorizer)1 JMXResource (org.apache.cassandra.auth.JMXResource)1 PasswordAuthenticator (org.apache.cassandra.auth.PasswordAuthenticator)1