Skip to content

Commit 995dc62

Browse files
committed
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]>
1 parent 004ccc7 commit 995dc62

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
@@ -1307,9 +1307,6 @@ void rgw::auth::RoleApplier::modify_request_state(const DoutPrefixProvider *dpp,
13071307
for (auto& it : token_attrs.token_claims) {
13081308
s->token_claims.emplace_back(it);
13091309
}
1310-
if (is_system_request) {
1311-
s->system_request = true;
1312-
}
13131310
}
13141311

13151312
rgw::auth::Engine::result_t

src/rgw/rgw_auth.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -798,20 +798,17 @@ class RoleApplier : public IdentityApplier {
798798
rgw::sal::Driver* driver;
799799
Role role;
800800
TokenAttrs token_attrs;
801-
bool is_system_request;
802801

803802
public:
804803

805804
RoleApplier(CephContext* const cct,
806805
rgw::sal::Driver* driver,
807806
const Role& role,
808-
const TokenAttrs& token_attrs,
809-
bool is_system_request)
807+
const TokenAttrs& token_attrs)
810808
: cct(cct),
811809
driver(driver),
812810
role(role),
813-
token_attrs(token_attrs),
814-
is_system_request(is_system_request) {}
811+
token_attrs(token_attrs) {}
815812

816813
ACLOwner get_aclowner() const override;
817814
uint32_t get_perms_from_aclspec(const DoutPrefixProvider* dpp, const aclspec_t& aclspec) const override {
@@ -847,7 +844,7 @@ class RoleApplier : public IdentityApplier {
847844
const req_state* s,
848845
Role role,
849846
TokenAttrs token_attrs,
850-
bool is_system_request) const = 0;
847+
bool is_impersonating) const = 0;
851848
};
852849
};
853850

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
@@ -7024,7 +7024,6 @@ rgw::auth::s3::STSEngine::authenticate(
70247024
const req_state* const s,
70257025
optional_yield y) const
70267026
{
7027-
bool is_system_request{false};
70287027
if (! s->info.args.exists("x-amz-security-token") &&
70297028
! s->info.env->exists("HTTP_X_AMZ_SECURITY_TOKEN") &&
70307029
s->auth.s3_postobj_creds.x_amz_security_token.empty()) {
@@ -7036,6 +7035,7 @@ rgw::auth::s3::STSEngine::authenticate(
70367035
return result_t::reject(ret);
70377036
}
70387037
//Authentication
7038+
bool is_impersonating = false;
70397039
std::string secret_access_key;
70407040
//Check if access key is not the same passed in by client
70417041
if (token.access_key_id != _access_key_id) {
@@ -7059,7 +7059,7 @@ rgw::auth::s3::STSEngine::authenticate(
70597059
}
70607060
const RGWAccessKey& k = iter->second;
70617061
secret_access_key = k.key;
7062-
is_system_request = true;
7062+
is_impersonating = true;
70637063
} else {
70647064
ldpp_dout(dpp, 0) << "Invalid access key" << dendl;
70657065
return result_t::reject(-EPERM);
@@ -7150,7 +7150,7 @@ rgw::auth::s3::STSEngine::authenticate(
71507150
t_attrs.token_issued_at = std::move(token.issued_at);
71517151
t_attrs.principal_tags = std::move(token.principal_tags);
71527152
auto apl = role_apl_factory->create_apl_role(cct, s, std::move(r),
7153-
std::move(t_attrs), is_system_request);
7153+
std::move(t_attrs), is_impersonating);
71547154
return result_t::grant(std::move(apl), completer_factory(token.secret_access_key));
71557155
} else { // This is for all local users of type TYPE_RGW|ROOT|NONE
71567156
if (token.user.empty()) {

0 commit comments

Comments
 (0)