]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: code changes to include tenant in replicated metadata
authorPritha Srivastava <prsrivas@redhat.com>
Tue, 25 Jan 2022 16:43:15 +0000 (22:13 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Mon, 6 Jun 2022 10:49:43 +0000 (16:19 +0530)
for roles.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/rgw_role.cc
src/rgw/rgw_role.h

index 1d311e8fab7bbf02cf4186d09940ea0be6a43f11..93cfa9e64803550824a278b0d4ff5d11297a54c0 100644 (file)
@@ -39,7 +39,8 @@ const string RGWRole::role_arn_prefix = "arn:aws:iam::";
 void RGWRoleInfo::dump(Formatter *f) const
 {
   encode_json("RoleId", id , f);
-  encode_json("RoleName", name , f);
+  std::string role_name = tenant + '$' + name;
+  encode_json("RoleName", role_name , f);
   encode_json("Path", path, f);
   encode_json("Arn", arn, f);
   encode_json("CreateDate", creation_date, f);
@@ -68,6 +69,10 @@ void RGWRoleInfo::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("CreateDate", creation_date, obj);
   JSONDecoder::decode_json("MaxSessionDuration", max_session_duration, obj);
   JSONDecoder::decode_json("AssumeRolePolicyDocument", trust_policy, obj);
+  if (auto pos = name.find('$'); pos != std::string::npos) {
+    tenant = name.substr(0, pos);
+    name = name.substr(pos+1);
+  }
 }
 
 RGWRole::RGWRole(std::string name,
index 97f517fe0fbad3af7e2fa4283d5bcd6a2e303136..ac124d777719cfb500235864896cb97ed939b9f0 100644 (file)
@@ -152,7 +152,7 @@ class RGWRoleMetadataObject: public RGWMetadataObject {
   Store* store;
 public:
   RGWRoleMetadataObject() = default;
-  RGWRoleMetadataObject(RGWRoleInfo info,
+  RGWRoleMetadataObject(RGWRoleInfo& info,
                        const obj_version& v,
                        real_time m,
       Store* store) : RGWMetadataObject(v,m), info(info), store(store) {}