use of com.hortonworks.streamline.streams.security.Roles in project streamline by hortonworks.
the class DefaultStreamlineAuthorizer method mayBeAssignAdminRole.
private void mayBeAssignAdminRole() {
LOG.info("Checking if admin users have admin role");
Role adminRole = catalogService.getRole(Roles.ROLE_ADMIN).orElseGet(() -> {
Role admin = new Role();
admin.setName("ROLE_ADMIN");
admin.setDisplayName("Admin");
admin.setDescription("Super user role that has all the system roles and privileges");
admin.setMetadata("{\"colorCode\":\"#8261be\",\"colorLabel\":\"purple\",\"icon\":\"gears\", \"menu\": [\"schemaRegistry\", \"modelRegistry\", \"udf\", \"dashboard\", \"topology\", \"authorizer\", \"notifier\", \"customprocessor\", \"servicepool\", \"environments\"], \"capabilities\": [{\"Applications\": \"Edit\"}, {\"Service Pool\": \"Edit\"}, {\"Environments\": \"Edit\"}, {\"Users\": \"Edit\"}, {\"Dashboard\": \"Edit\"}]}");
admin.setSystem(false);
return catalogService.addRole(admin);
});
adminUsers.stream().map(userName -> catalogService.getUser(userName)).filter(user -> {
if (userHasRole(user, Roles.ROLE_ADMIN)) {
LOG.info("user '{}' already has '{}'", user, Roles.ROLE_ADMIN);
return false;
} else {
return true;
}
}).forEach(user -> catalogService.addUserRole(user.getId(), adminRole.getId()));
}
Aggregations