From b62311b3f2b6037df29ff6d7fb10cc2f6bfa75e7 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 22 Nov 2019 16:48:27 -0800 Subject: [PATCH] rgw: auth: api to create auth identity without req_state Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_auth.cc | 34 +++++++++++++++++++++++++--------- src/rgw/rgw_auth.h | 6 ++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index cc2f822350c22..b18d91832c3b9 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -21,7 +21,11 @@ namespace rgw { namespace auth { std::unique_ptr -transform_old_authinfo(const req_state* const s) +transform_old_authinfo(CephContext* const cct, + const rgw_user& auth_id, + const int perm_mask, + const bool is_admin, + const uint32_t type) { /* This class is not intended for public use. Should be removed altogether * with this function after moving all our APIs to the new authentication @@ -38,14 +42,15 @@ transform_old_authinfo(const req_state* const s) const uint32_t type; public: DummyIdentityApplier(CephContext* const cct, - const sal::RGWUser* user, + const rgw_user& auth_id, const int perm_mask, - const bool is_admin) + const bool is_admin, + const uint32_t type) : cct(cct), - id(user->get_id()), + id(auth_id), perm_mask(perm_mask), is_admin(is_admin), - type(user->get_type()) { + type(type) { } uint32_t get_perms_from_aclspec(const DoutPrefixProvider* dpp, const aclspec_t& aclspec) const override { @@ -95,12 +100,23 @@ transform_old_authinfo(const req_state* const s) }; return std::unique_ptr( - new DummyIdentityApplier(s->cct, - s->user, - s->perm_mask, + new DummyIdentityApplier(cct, + auth_id, + perm_mask, + is_admin, + type)); +} + +std::unique_ptr +transform_old_authinfo(const req_state* const s) +{ + return transform_old_authinfo(s->cct, + s->user->get_id(), + s->perm_mask, /* System user has admin permissions by default - it's supposed to pass * through any security check. */ - s->system_request)); + s->system_request, + s->user->get_type()); } } /* namespace auth */ diff --git a/src/rgw/rgw_auth.h b/src/rgw/rgw_auth.h index 37513f272a751..38f51b790a8f8 100644 --- a/src/rgw/rgw_auth.h +++ b/src/rgw/rgw_auth.h @@ -85,6 +85,12 @@ inline std::ostream& operator<<(std::ostream& out, } +std::unique_ptr +transform_old_authinfo(CephContext* const cct, + const rgw_user& auth_id, + const int perm_mask, + const bool is_admin, + const uint32_t type); std::unique_ptr transform_old_authinfo(const req_state* const s); -- 2.47.3