From: Casey Bodley Date: Thu, 7 Dec 2023 21:56:27 +0000 (-0500) Subject: rgw/auth: initialize s->owner in Strategy::apply() X-Git-Tag: v20.0.0~2159^2~165 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9989a86dd7a586d292cae0de32f7723b93147edc;p=ceph.git rgw/auth: initialize s->owner in Strategy::apply() for a common location that applies to all rest handlers that implement authorize() Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index 91107c60c995..dcf835996844 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -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; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index a70b043318d8..24392bc0caa7 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1138,6 +1138,7 @@ struct req_state : DoutPrefixProvider { std::string src_bucket_name; std::unique_ptr src_object; ACLOwner bucket_owner; + // Resource owner for the authenticated identity, initialized in authorize() ACLOwner owner; std::string zonegroup_name; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 13383b78c33f..c2225589216f 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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,