Search in sources :

Example 1 with SecurityBasicPermissionSet

use of org.apache.ignite.plugin.security.SecurityBasicPermissionSet in project ignite by apache.

the class TestSecurityProcessor method authenticate.

/**
 * {@inheritDoc}
 */
@Override
public SecurityContext authenticate(AuthenticationContext ctx) throws IgniteCheckedException {
    if (ctx.credentials() == null || ctx.credentials().getLogin() == null)
        return null;
    SecurityPermissionSet perms = PERMS.get(ctx.credentials());
    if (perms == null) {
        perms = new SecurityBasicPermissionSet();
        ((SecurityBasicPermissionSet) perms).setDefaultAllowAll(true);
    }
    SecurityContext res = new TestSecurityContext(new TestSecuritySubject().setType(ctx.subjectType()).setId(ctx.subjectId()).setAddr(ctx.address()).setLogin(ctx.credentials().getLogin()).setPerms(perms).setCerts(ctx.certificates()).sandboxPermissions(SANDBOX_PERMS.get(ctx.credentials())));
    SECURITY_CONTEXTS.put(res.subject().id(), res);
    return res;
}
Also used : SecurityPermissionSet(org.apache.ignite.plugin.security.SecurityPermissionSet) SecurityContext(org.apache.ignite.internal.processors.security.SecurityContext) SecurityBasicPermissionSet(org.apache.ignite.plugin.security.SecurityBasicPermissionSet)

Example 2 with SecurityBasicPermissionSet

use of org.apache.ignite.plugin.security.SecurityBasicPermissionSet in project ignite by apache.

the class JdbcAuthorizationTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    super.beforeTestsStarted();
    Ignite srv = startSecurityGrid(0, new TestSecurityData(EMPTY_PERMS_USER, new SecurityBasicPermissionSet()), new TestSecurityData(CACHE_CREATE_SYS_PERM_USER, systemPermissions(CACHE_CREATE)), new TestSecurityData(CACHE_DESTROY_SYS_PERMS_USER, systemPermissions(CACHE_DESTROY)), new TestSecurityData(CACHE_CREATE_CACHE_PERMS_USER, cachePermissions(TEST_CREATE_TABLE_CACHE, CACHE_CREATE)), new TestSecurityData(CACHE_DESTROY_CACHE_PERMS_USER, cachePermissions(TEST_DROP_TABLE_CACHE, CACHE_DESTROY)), new TestSecurityData(CACHE_READ_USER, cachePermissions(DEFAULT_CACHE_NAME, CACHE_READ)), new TestSecurityData(CACHE_PUT_USER, create().defaultAllowAll(false).appendCachePermissions(DEFAULT_CACHE_NAME, CACHE_PUT).appendCachePermissions(TEST_BULKLOAD_CACHE, CACHE_PUT).build()), new TestSecurityData(CACHE_REMOVE_USER, cachePermissions(DEFAULT_CACHE_NAME, CACHE_REMOVE)));
    startSecurityGrid(1);
    srv.cluster().state(ACTIVE);
    CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg.setIndexedTypes(Integer.class, Integer.class);
    ccfg.setCacheMode(REPLICATED);
    ccfg.setSqlSchema(TEST_DML_SCHEMA);
    srv.createCache(ccfg);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestSecurityData(org.apache.ignite.internal.processors.security.impl.TestSecurityData) Ignite(org.apache.ignite.Ignite) SecurityBasicPermissionSet(org.apache.ignite.plugin.security.SecurityBasicPermissionSet) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

SecurityBasicPermissionSet (org.apache.ignite.plugin.security.SecurityBasicPermissionSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Ignite (org.apache.ignite.Ignite)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 SecurityContext (org.apache.ignite.internal.processors.security.SecurityContext)1 TestSecurityData (org.apache.ignite.internal.processors.security.impl.TestSecurityData)1 SecurityPermissionSet (org.apache.ignite.plugin.security.SecurityPermissionSet)1