Search in sources :

Example 1 with BasicRoleBasedAuthorizer

use of org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer in project druid by druid-io.

the class CoordinatorPollingBasicAuthorizerCacheManager method initUserMaps.

private void initUserMaps() {
    AuthorizerMapper authorizerMapper = injector.getInstance(AuthorizerMapper.class);
    if (authorizerMapper == null || authorizerMapper.getAuthorizerMap() == null) {
        return;
    }
    for (Map.Entry<String, Authorizer> entry : authorizerMapper.getAuthorizerMap().entrySet()) {
        Authorizer authorizer = entry.getValue();
        if (authorizer instanceof BasicRoleBasedAuthorizer) {
            String authorizerName = entry.getKey();
            authorizerPrefixes.add(authorizerName);
            UserAndRoleMap userAndRoleMap = fetchUserAndRoleMapFromCoordinator(authorizerName, true);
            if (userAndRoleMap != null) {
                cachedUserMaps.put(authorizerName, userAndRoleMap.getUserMap());
                cachedRoleMaps.put(authorizerName, userAndRoleMap.getRoleMap());
            }
            GroupMappingAndRoleMap groupMappingAndRoleMap = fetchGroupAndRoleMapFromCoordinator(authorizerName, true);
            if (groupMappingAndRoleMap != null) {
                cachedGroupMappingMaps.put(authorizerName, groupMappingAndRoleMap.getGroupMappingMap());
                cachedGroupMappingRoleMaps.put(authorizerName, groupMappingAndRoleMap.getRoleMap());
            }
        }
    }
}
Also used : UserAndRoleMap(org.apache.druid.security.basic.authorization.entity.UserAndRoleMap) GroupMappingAndRoleMap(org.apache.druid.security.basic.authorization.entity.GroupMappingAndRoleMap) BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer) Authorizer(org.apache.druid.server.security.Authorizer) AuthorizerMapper(org.apache.druid.server.security.AuthorizerMapper) BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer) UserAndRoleMap(org.apache.druid.security.basic.authorization.entity.UserAndRoleMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GroupMappingAndRoleMap(org.apache.druid.security.basic.authorization.entity.GroupMappingAndRoleMap)

Example 2 with BasicRoleBasedAuthorizer

use of org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer in project druid by druid-io.

the class CoordinatorBasicAuthorizerResourceHandler method getAllRoles.

@Override
public Response getAllRoles(String authorizerName) {
    final BasicRoleBasedAuthorizer authorizer = authorizerMap.get(authorizerName);
    if (authorizer == null) {
        return makeResponseForAuthorizerNotFound(authorizerName);
    }
    Map<String, BasicAuthorizerRole> roleMap = BasicAuthUtils.deserializeAuthorizerRoleMap(objectMapper, storageUpdater.getCurrentRoleMapBytes(authorizerName));
    return Response.ok(roleMap.keySet()).build();
}
Also used : BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer) BasicAuthorizerRole(org.apache.druid.security.basic.authorization.entity.BasicAuthorizerRole)

Example 3 with BasicRoleBasedAuthorizer

use of org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer in project druid by druid-io.

the class CoordinatorBasicAuthorizerResourceHandler method getAllGroupMappings.

@Override
public Response getAllGroupMappings(String authorizerName) {
    final BasicRoleBasedAuthorizer authorizer = authorizerMap.get(authorizerName);
    if (authorizer == null) {
        return makeResponseForAuthorizerNotFound(authorizerName);
    }
    Map<String, BasicAuthorizerGroupMapping> groupMappingMap = BasicAuthUtils.deserializeAuthorizerGroupMappingMap(objectMapper, storageUpdater.getCurrentGroupMappingMapBytes(authorizerName));
    return Response.ok(groupMappingMap.keySet()).build();
}
Also used : BasicAuthorizerGroupMapping(org.apache.druid.security.basic.authorization.entity.BasicAuthorizerGroupMapping) BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer)

Example 4 with BasicRoleBasedAuthorizer

use of org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer in project druid by druid-io.

the class CoordinatorBasicAuthorizerResourceHandler method getAllUsers.

@Override
public Response getAllUsers(String authorizerName) {
    final BasicRoleBasedAuthorizer authorizer = authorizerMap.get(authorizerName);
    if (authorizer == null) {
        return makeResponseForAuthorizerNotFound(authorizerName);
    }
    Map<String, BasicAuthorizerUser> userMap = BasicAuthUtils.deserializeAuthorizerUserMap(objectMapper, storageUpdater.getCurrentUserMapBytes(authorizerName));
    return Response.ok(userMap.keySet()).build();
}
Also used : BasicAuthorizerUser(org.apache.druid.security.basic.authorization.entity.BasicAuthorizerUser) BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer)

Example 5 with BasicRoleBasedAuthorizer

use of org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer in project druid by druid-io.

the class DefaultBasicAuthorizerResourceHandler method authorizerUserUpdateListener.

@Override
public Response authorizerUserUpdateListener(String authorizerName, byte[] serializedUserAndRoleMap) {
    final BasicRoleBasedAuthorizer authorizer = authorizerMap.get(authorizerName);
    if (authorizer == null) {
        log.error(UNKNOWN_AUTHORIZER_MSG_FORMAT, authorizerName);
        return Response.status(Response.Status.BAD_REQUEST).entity(ImmutableMap.<String, Object>of("error", StringUtils.format(UNKNOWN_AUTHORIZER_MSG_FORMAT, authorizerName))).build();
    }
    cacheManager.handleAuthorizerUserUpdate(authorizerName, serializedUserAndRoleMap);
    return Response.ok().build();
}
Also used : BasicRoleBasedAuthorizer(org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer)

Aggregations

BasicRoleBasedAuthorizer (org.apache.druid.security.basic.authorization.BasicRoleBasedAuthorizer)13 AuthorizerMapper (org.apache.druid.server.security.AuthorizerMapper)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)3 Map (java.util.Map)3 BasicAuthCommonCacheConfig (org.apache.druid.security.basic.BasicAuthCommonCacheConfig)3 CoordinatorBasicAuthorizerMetadataStorageUpdater (org.apache.druid.security.basic.authorization.db.updater.CoordinatorBasicAuthorizerMetadataStorageUpdater)3 GroupMappingAndRoleMap (org.apache.druid.security.basic.authorization.entity.GroupMappingAndRoleMap)3 UserAndRoleMap (org.apache.druid.security.basic.authorization.entity.UserAndRoleMap)3 Authorizer (org.apache.druid.server.security.Authorizer)3 Before (org.junit.Before)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 MetadataStorageTablesConfig (org.apache.druid.metadata.MetadataStorageTablesConfig)2 TestDerbyConnector (org.apache.druid.metadata.TestDerbyConnector)2 BasicAuthDBConfig (org.apache.druid.security.basic.BasicAuthDBConfig)2 BasicAuthorizerGroupMapping (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerGroupMapping)2 BasicAuthorizerRole (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerRole)2 BasicAuthorizerUser (org.apache.druid.security.basic.authorization.entity.BasicAuthorizerUser)2 HashMap (java.util.HashMap)1 BasicAttribute (javax.naming.directory.BasicAttribute)1