]> git.apps.os.sepia.ceph.com Git - ceph-ci.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>
Wed, 10 Apr 2024 16:53:04 +0000 (12:53 -0400)
for a common location that applies to all rest handlers that implement
authorize()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
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 a70b043318d884b9584ba45019343002fe6c66a7..24392bc0caa75c3c28a3701298ea1ecba568ee95 100644 (file)
@@ -1138,6 +1138,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 13383b78c33ff1b24fdce995acb66714e2c877c4..c2225589216fd3081f40c15a9b6070f5b5e7257e 100644 (file)
@@ -3148,9 +3148,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;
     }
 
@@ -5080,13 +5077,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,