From bf204e982ea5b9e1ad0b6f7a1433404245b2137e Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Sat, 20 Jan 2024 15:16:00 -0500 Subject: [PATCH] rgw/role: separate dump_iam_role() for iam api create a new dump_iam_role() for iam api responses that dumps the subset of role information presented by the apis RGWRoleInfo::dump() and decode_json() are used by metadata sync to transfer role metadata between zones, so must contain all information about the role Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 4 ++-- src/rgw/rgw_rest_role.cc | 15 +++++++++++++-- src/rgw/rgw_role.cc | 10 ---------- src/rgw/rgw_role.h | 2 -- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index badb43b3c1904..33355ec273514 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6792,7 +6792,7 @@ int main(int argc, const char **argv) if (ret < 0) { return -ret; } - encode_json("role", *role, formatter.get()); + encode_json("role", role->get_info(), formatter.get()); formatter->flush(cout); return 0; } @@ -6821,7 +6821,7 @@ int main(int argc, const char **argv) if (ret < 0) { return -ret; } - encode_json("role", *role, formatter.get()); + encode_json("role", role->get_info(), formatter.get()); formatter->flush(cout); return 0; } diff --git a/src/rgw/rgw_rest_role.cc b/src/rgw/rgw_rest_role.cc index 05450491f440e..463ed5eb08c81 100644 --- a/src/rgw/rgw_rest_role.cc +++ b/src/rgw/rgw_rest_role.cc @@ -40,6 +40,17 @@ int RGWRestRole::check_caps(const RGWUserCaps& caps) return caps.check_cap("roles", perm); } +static void dump_iam_role(const rgw::sal::RGWRoleInfo& role, Formatter *f) +{ + encode_json("RoleId", role.id, f); + encode_json("RoleName", role.name, f); + encode_json("Path", role.path, f); + encode_json("Arn", role.arn, f); + encode_json("CreateDate", role.creation_date, f); + encode_json("MaxSessionDuration", role.max_session_duration, f); + encode_json("AssumeRolePolicyDocument", role.trust_policy, f); +} + static int parse_tags(const DoutPrefixProvider* dpp, const std::map& params, std::multimap& tags, @@ -278,7 +289,7 @@ void RGWCreateRole::execute(optional_yield y) s->formatter->open_object_section("CreateRoleResponse"); s->formatter->open_object_section("CreateRoleResult"); s->formatter->open_object_section("Role"); - role->dump(s->formatter); + dump_iam_role(role->get_info(), s->formatter); s->formatter->close_section(); s->formatter->close_section(); s->formatter->open_object_section("ResponseMetadata"); @@ -366,7 +377,7 @@ void RGWGetRole::execute(optional_yield y) s->formatter->close_section(); s->formatter->open_object_section("GetRoleResult"); s->formatter->open_object_section("Role"); - role->dump(s->formatter); + dump_iam_role(role->get_info(), s->formatter); s->formatter->close_section(); s->formatter->close_section(); s->formatter->close_section(); diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index fb188e7f80fa3..12e79d433ea13 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -169,16 +169,6 @@ int RGWRole::get_by_id(const DoutPrefixProvider *dpp, optional_yield y) return 0; } -void RGWRole::dump(Formatter *f) const -{ - info.dump(f); -} - -void RGWRole::decode_json(JSONObj *obj) -{ - info.decode_json(obj); -} - bool RGWRole::validate_max_session_duration(const DoutPrefixProvider* dpp) { if (info.max_session_duration < SESSION_DURATION_MIN || diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index 9183829d976b0..77d315fc96e3a 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -140,8 +140,6 @@ public: boost::optional> get_tags(); void erase_tags(const std::vector& tagKeys); void update_max_session_duration(const std::string& max_session_duration_str); - void dump(Formatter *f) const; - void decode_json(JSONObj *obj); static const std::string& get_names_oid_prefix(); static const std::string& get_info_oid_prefix(); -- 2.39.5