Skip to content

Commit

Permalink
rgw/auth: initialize s->owner in Strategy::apply()
Browse files Browse the repository at this point in the history
for a common location that applies to all rest handlers that implement
authorize()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
  • Loading branch information
cbodley committed Apr 10, 2024
1 parent 4b8cea0 commit 9989a86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/rgw/rgw_auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 1 addition & 10 deletions src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9989a86

Please sign in to comment.