Skip to content

Commit a5cb8a4

Browse files
clwluvwcbodley
authored andcommitted
rgw: utilize is_impersonating for forwarded sts requests
With the introduction of is_impersonating in SysReqApplier, RoleApplier can now use the same mechanism to mark when a request has been forwarded by a system user on behalf of another role (e.g., through STS) to mark it as a system request (s->system_request). Signed-off-by: Seena Fallah <[email protected]> (cherry picked from commit 995dc62)
1 parent 0719988 commit a5cb8a4

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/rgw/rgw_auth.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,9 +1297,6 @@ void rgw::auth::RoleApplier::modify_request_state(const DoutPrefixProvider *dpp,
12971297
for (auto& it : token_attrs.token_claims) {
12981298
s->token_claims.emplace_back(it);
12991299
}
1300-
if (is_system_request) {
1301-
s->system_request = true;
1302-
}
13031300
}
13041301

13051302
rgw::auth::Engine::result_t

src/rgw/rgw_auth.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,20 +794,17 @@ class RoleApplier : public IdentityApplier {
794794
rgw::sal::Driver* driver;
795795
Role role;
796796
TokenAttrs token_attrs;
797-
bool is_system_request;
798797

799798
public:
800799

801800
RoleApplier(CephContext* const cct,
802801
rgw::sal::Driver* driver,
803802
const Role& role,
804-
const TokenAttrs& token_attrs,
805-
bool is_system_request)
803+
const TokenAttrs& token_attrs)
806804
: cct(cct),
807805
driver(driver),
808806
role(role),
809-
token_attrs(token_attrs),
810-
is_system_request(is_system_request) {}
807+
token_attrs(token_attrs) {}
811808

812809
ACLOwner get_aclowner() const override;
813810
uint32_t get_perms_from_aclspec(const DoutPrefixProvider* dpp, const aclspec_t& aclspec) const override {
@@ -843,7 +840,7 @@ class RoleApplier : public IdentityApplier {
843840
const req_state* s,
844841
Role role,
845842
TokenAttrs token_attrs,
846-
bool is_system_request) const = 0;
843+
bool is_impersonating) const = 0;
847844
};
848845
};
849846

src/rgw/rgw_auth_s3.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class STSAuthStrategy : public rgw::auth::Strategy,
7272
const req_state* const s,
7373
RoleApplier::Role role,
7474
RoleApplier::TokenAttrs token_attrs,
75-
bool is_system_request) const override {
75+
bool is_impersonating) const override {
7676
auto apl = rgw::auth::add_sysreq(cct, driver, s,
77-
rgw::auth::RoleApplier(cct, driver, std::move(role), std::move(token_attrs), is_system_request));
77+
rgw::auth::RoleApplier(cct, driver, std::move(role), std::move(token_attrs)), is_impersonating);
7878
return aplptr_t(new decltype(apl)(std::move(apl)));
7979
}
8080

src/rgw/rgw_rest_s3.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7022,7 +7022,6 @@ rgw::auth::s3::STSEngine::authenticate(
70227022
const req_state* const s,
70237023
optional_yield y) const
70247024
{
7025-
bool is_system_request{false};
70267025
if (! s->info.args.exists("x-amz-security-token") &&
70277026
! s->info.env->exists("HTTP_X_AMZ_SECURITY_TOKEN") &&
70287027
s->auth.s3_postobj_creds.x_amz_security_token.empty()) {
@@ -7034,6 +7033,7 @@ rgw::auth::s3::STSEngine::authenticate(
70347033
return result_t::reject(ret);
70357034
}
70367035
//Authentication
7036+
bool is_impersonating = false;
70377037
std::string secret_access_key;
70387038
//Check if access key is not the same passed in by client
70397039
if (token.access_key_id != _access_key_id) {
@@ -7057,7 +7057,7 @@ rgw::auth::s3::STSEngine::authenticate(
70577057
}
70587058
const RGWAccessKey& k = iter->second;
70597059
secret_access_key = k.key;
7060-
is_system_request = true;
7060+
is_impersonating = true;
70617061
} else {
70627062
ldpp_dout(dpp, 0) << "Invalid access key" << dendl;
70637063
return result_t::reject(-EPERM);
@@ -7148,7 +7148,7 @@ rgw::auth::s3::STSEngine::authenticate(
71487148
t_attrs.token_issued_at = std::move(token.issued_at);
71497149
t_attrs.principal_tags = std::move(token.principal_tags);
71507150
auto apl = role_apl_factory->create_apl_role(cct, s, std::move(r),
7151-
std::move(t_attrs), is_system_request);
7151+
std::move(t_attrs), is_impersonating);
71527152
return result_t::grant(std::move(apl), completer_factory(token.secret_access_key));
71537153
} else { // This is for all local users of type TYPE_RGW|ROOT|NONE
71547154
if (token.user.empty()) {

0 commit comments

Comments
 (0)