]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw : add check for tenant provided in RGWCreateRole 43270/head
authorcao.leilc <cao.leilc@inspur.com>
Thu, 17 Jun 2021 12:04:23 +0000 (20:04 +0800)
committerCory Snyder <csnyder@iland.com>
Wed, 29 Sep 2021 14:34:42 +0000 (10:34 -0400)
Fixes: https://tracker.ceph.com/issues/51206
Signed-off-by: caolei <halei15848934852@163.com>
(cherry picked from commit 3c99ac14080c9f5b1611c9bbe4a223a9fd2927a0)

Conflicts:
src/rgw/rgw_rest_role.cc

- Octopus constructs role explicitly vs. using store->get_role(), and does not wrap in a unique_ptr

src/rgw/rgw_rest_role.cc

index cb3b2c8566bddca2c7aa908363d52a9e1da52ecd..473e670d02ba4b382444ae3221537404806dccdf 100644 (file)
@@ -129,8 +129,15 @@ void RGWCreateRole::execute()
   if (op_ret < 0) {
     return;
   }
+  std::string user_tenant = s->user->get_tenant();
   RGWRole role(s->cct, store->getRados()->pctl, role_name, role_path, trust_policy,
-                s->user->get_tenant(), max_session_duration);
+               user_tenant, max_session_duration);
+  if (!user_tenant.empty() && role.get_tenant() != user_tenant) {
+    ldpp_dout(this, 20) << "ERROR: the tenant provided in the role name does not match with the tenant of the user creating the role"
+    << dendl;
+    op_ret = -EINVAL;
+    return;
+  }
   op_ret = role.create(true);
 
   if (op_ret == -EEXIST) {