Search in sources :

Example 6 with IRoleManager

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

the class NetworkPermissionsCacheKeysTableTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // high value is used for convenient debugging
    DatabaseDescriptor.setPermissionsValidity(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());
    INetworkAuthorizer networkAuthorizer = DatabaseDescriptor.getNetworkAuthorizer();
    networkAuthorizer.setRoleDatacenters(ROLE_A, DCPermissions.all());
    networkAuthorizer.setRoleDatacenters(ROLE_B, DCPermissions.subset(DATA_CENTER, DATA_CENTER_REMOTE));
}
Also used : INetworkAuthorizer(org.apache.cassandra.auth.INetworkAuthorizer) IRoleManager(org.apache.cassandra.auth.IRoleManager) BeforeClass(org.junit.BeforeClass)

Example 7 with IRoleManager

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

the class JmxPermissionsCacheKeysTableTest method setup.

// this method is intentionally not called "setUpClass" to let it throw exception brought by startJMXServer method
@BeforeClass
public static void setup() throws Exception {
    // high value is used for convenient debugging
    DatabaseDescriptor.setPermissionsValidity(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());
    List<IResource> resources = Arrays.asList(JMXResource.root(), JMXResource.mbean("org.apache.cassandra.db:type=Tables,*"));
    IAuthorizer authorizer = DatabaseDescriptor.getAuthorizer();
    for (IResource resource : resources) {
        Set<Permission> permissions = resource.applicablePermissions();
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_A);
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_B);
    }
    startJMXServer();
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) IAuthorizer(org.apache.cassandra.auth.IAuthorizer) Permission(org.apache.cassandra.auth.Permission) IResource(org.apache.cassandra.auth.IResource) BeforeClass(org.junit.BeforeClass)

Example 8 with IRoleManager

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

the class PermissionsCacheKeysTableTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // high value is used for convenient debugging
    DatabaseDescriptor.setPermissionsValidity(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());
    List<IResource> resources = Arrays.asList(DataResource.root(), DataResource.keyspace(KEYSPACE), DataResource.table(KEYSPACE, "t1"));
    IAuthorizer authorizer = DatabaseDescriptor.getAuthorizer();
    for (IResource resource : resources) {
        Set<Permission> permissions = resource.applicablePermissions();
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_A);
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_B);
    }
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) IAuthorizer(org.apache.cassandra.auth.IAuthorizer) Permission(org.apache.cassandra.auth.Permission) IResource(org.apache.cassandra.auth.IResource) BeforeClass(org.junit.BeforeClass)

Example 9 with IRoleManager

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

the class InvalidatePermissionsCacheTest 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());
    AuthCacheService.initializeAndRegisterCaches();
    List<IResource> resources = Arrays.asList(DataResource.root(), DataResource.keyspace(KEYSPACE), DataResource.allTables(KEYSPACE), DataResource.table(KEYSPACE, "t1"), RoleResource.root(), RoleResource.role("role_x"), FunctionResource.root(), FunctionResource.keyspace(KEYSPACE), // CQLTester.createFunction from static contex. That's why we initialize it in a separate test case.
    JMXResource.root(), JMXResource.mbean("org.apache.cassandra.auth:type=*"));
    IAuthorizer authorizer = DatabaseDescriptor.getAuthorizer();
    for (IResource resource : resources) {
        Set<Permission> permissions = resource.applicablePermissions();
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_A);
        authorizer.grant(AuthenticatedUser.SYSTEM_USER, permissions, resource, ROLE_B);
    }
    startJMXServer();
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) IAuthorizer(org.apache.cassandra.auth.IAuthorizer) Permission(org.apache.cassandra.auth.Permission) IResource(org.apache.cassandra.auth.IResource) BeforeClass(org.junit.BeforeClass)

Example 10 with IRoleManager

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

the class InvalidateNetworkPermissionsCacheTest 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());
    AuthCacheService.initializeAndRegisterCaches();
    startJMXServer();
}
Also used : IRoleManager(org.apache.cassandra.auth.IRoleManager) 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