]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/auth: initialize s->owner in Strategy::apply()
authorCasey Bodley <cbodley@redhat.com>
Thu, 7 Dec 2023 21:56:27 +0000 (16:56 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:25 +0000 (15:34 -0400)
for a common location that applies to all rest handlers that implement
authorize()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9989a86dd7a586d292cae0de32f7723b93147edc)

src/rgw/rgw_auth.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index 91107c60c9954046ac3de2c073d45f3697ca6b48..dcf835996844578a5e63745a755ce76a5ac7e58d 100644 (file)
@@ -348,6 +348,9 @@ rgw::auth::Strategy::apply(const DoutPrefixProvider *dpp, const rgw::auth::Strat
       s->auth.identity = std::move(applier);
       s->auth.completer = std::move(completer);
 
+      /* Populate the owner info. */
+      s->owner = s->auth.identity->get_aclowner();
+
       return 0;
     } catch (const int err) {
       ldpp_dout(dpp, 5) << "applier throwed err=" << err << dendl;
index 5dc4f883a174aa39e59f50cd2252414cf1af33a4..897b06ac2820a908fd9588e0fcbd0c8be7001039 100644 (file)
@@ -1137,6 +1137,7 @@ struct req_state : DoutPrefixProvider {
   std::string src_bucket_name;
   std::unique_ptr<rgw::sal::Object> src_object;
   ACLOwner bucket_owner;
+  // Resource owner for the authenticated identity, initialized in authorize()
   ACLOwner owner;
 
   std::string zonegroup_name;
index a51dbe23aea7f3d590b033bb88d2275a65ea498f..917207c58aac42fb8f3b40b290d27bd685c83a53 100644 (file)
@@ -3137,9 +3137,6 @@ int RGWPostObj_ObjStore_S3::get_policy(optional_yield y)
     if (ret != 0) {
       return -EACCES;
     } else {
-      /* Populate the owner info. */
-      s->owner.id = s->user->get_id();
-      s->owner.display_name = s->user->get_display_name();
       ldpp_dout(this, 20) << "Successful Signature Verification!" << dendl;
     }
 
@@ -5069,13 +5066,7 @@ int RGW_Auth_S3::authorize(const DoutPrefixProvider *dpp,
     return -EPERM;
   }
 
-  const auto ret = rgw::auth::Strategy::apply(dpp, auth_registry.get_s3_main(), s, y);
-  if (ret == 0) {
-    /* Populate the owner info. */
-    s->owner.id = s->user->get_id();
-    s->owner.display_name = s->user->get_display_name();
-  }
-  return ret;
+  return rgw::auth::Strategy::apply(dpp, auth_registry.get_s3_main(), s, y);
 }
 
 int RGWHandler_Auth_S3::init(rgw::sal::Driver* driver, req_state *state,