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());
}
}
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations