Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Ranger): Use Apache Ranger for meta access controller #1402

Merged
merged 8 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/meta/meta_backup_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "runtime/rpc/rpc_holder.h"
#include "runtime/rpc/rpc_message.h"
#include "runtime/rpc/serialization.h"
#include "runtime/security/access_controller.h"
#include "runtime/task/async_calls.h"
#include "runtime/task/task_code.h"
#include "server_state.h"
Expand Down Expand Up @@ -1248,6 +1249,7 @@ void backup_service::add_backup_policy(dsn::message_ex *msg)
configuration_add_backup_policy_request request;
configuration_add_backup_policy_response response;

dsn::message_ex *copied_msg = message_ex::copy_message_no_reply(*msg);
::dsn::unmarshall(msg, request);
std::set<int32_t> app_ids;
std::map<int32_t, std::string> app_names;
Expand Down Expand Up @@ -1280,6 +1282,20 @@ void backup_service::add_backup_policy(dsn::message_ex *msg)
msg->release_ref();
return;
}
// when the Ranger ACL is enabled, access control will be checked for each table.
auto access_controller = _meta_svc->get_access_controller();
// adding multiple judgments here is to adapt to the old ACL and avoid checking again.
if (access_controller->is_enable_ranger_acl() &&
!access_controller->allowed(copied_msg, app->app_name)) {
response.err = ERR_ACL_DENY;
response.hint_message =
fmt::format("not authorized to add backup policy({}) for app id: {}",
request.policy_name,
app_id);
_meta_svc->reply_data(msg, response);
msg->release_ref();
return;
}
app_ids.insert(app_id);
app_names.insert(std::make_pair(app_id, app->app_name));
}
Expand Down Expand Up @@ -1510,16 +1526,24 @@ void backup_service::modify_backup_policy(configuration_modify_backup_policy_rpc

for (const auto &appid : request.add_appids) {
const auto &app = _state->get_app(appid);
auto access_controller = _meta_svc->get_access_controller();
// TODO: if app is dropped, how to process
if (app == nullptr) {
LOG_WARNING("{}: add app to policy failed, because invalid app({}), ignore it",
cur_policy.policy_name,
appid);
} else {
valid_app_ids_to_add.emplace_back(appid);
id_to_app_names.insert(std::make_pair(appid, app->app_name));
have_modify_policy = true;
continue;
}
if (access_controller->is_enable_ranger_acl() &&
!access_controller->allowed(rpc.dsn_request(), app->app_name)) {
LOG_WARNING("not authorized to modify backup policy({}) for app id: {}, skip it",
cur_policy.policy_name,
appid);
continue;
}
valid_app_ids_to_add.emplace_back(appid);
id_to_app_names.insert(std::make_pair(appid, app->app_name));
have_modify_policy = true;
}
}

Expand Down
Loading