]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/role: separate dump_iam_role() for iam api
authorCasey Bodley <cbodley@redhat.com>
Sat, 20 Jan 2024 20:16:00 +0000 (15:16 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 10 Apr 2024 17:09:15 +0000 (13:09 -0400)
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 <cbodley@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rest_role.cc
src/rgw/rgw_role.cc
src/rgw/rgw_role.h

index badb43b3c1904d68f780db52c2e06490da7b766a..33355ec273514c1909ce409e6ccb9b0763831808 100644 (file)
@@ -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;
     }
index 05450491f440e33a9c18e1d1c62b797b2d8e89c2..463ed5eb08c8156e4cf916103d00488ef6603f31 100644 (file)
@@ -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<std::string, std::string>& params,
                       std::multimap<std::string, std::string>& 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();
index fb188e7f80fa3c2b435af46a26b7d29e34c04eac..12e79d433ea13e64c9e361cacffd519abd719f79 100644 (file)
@@ -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 ||
index 9183829d976b0417fc2ca8f971557b7495a3f83f..77d315fc96e3a3dc1478cdf5534ba281d87ff448 100644 (file)
@@ -140,8 +140,6 @@ public:
   boost::optional<std::multimap<std::string,std::string>> get_tags();
   void erase_tags(const std::vector<std::string>& 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();