Skip to content

Commit 4716655

Browse files
committed
RGW: When using Keystone auth for RGW, include the Keystone user in ops log
Signed-off-by: Ali Masarwa <[email protected]> Signed-off-by: Ali Masarwa <[email protected]>
1 parent 2e8b220 commit 4716655

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

qa/workunits/rgw/keystone-service-token.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
# GNU Library Public License for more details.
16+
#
17+
<<comment Running this script with vstart should be should have these options
18+
MON=1 OSD=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh -n -d -o 'rgw_keystone_accepted_admin_roles="admin"
19+
rgw_keystone_accepted_roles="admin,Member"
20+
rgw_keystone_admin_domain="Default"
21+
rgw_keystone_admin_password="ADMIN"
22+
rgw_keystone_admin_project="admin"
23+
rgw_keystone_admin_user="admin"
24+
rgw_keystone_api_version=3
25+
rgw_keystone_expired_token_cache_expiration=10
26+
rgw_keystone_implicit_tenants=true
27+
rgw_keystone_service_token_accepted_roles="admin"
28+
rgw_keystone_service_token_enabled=true
29+
rgw_keystone_url="http://localhost:5000"
30+
rgw_swift_account_in_url=true
31+
rgw_swift_enforce_content_length=true
32+
rgw_swift_versioning_enabled=true'
33+
comment
1634

1735
source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
1836

src/rgw/rgw_auth.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ bool rgw::auth::WebIdentityApplier::is_identity(const Principal& p) const
782782

783783
const std::string rgw::auth::RemoteApplier::AuthInfo::NO_SUBUSER;
784784
const std::string rgw::auth::RemoteApplier::AuthInfo::NO_ACCESS_KEY;
785+
const std::string rgw::auth::RemoteApplier::AuthInfo::NO_KEYSTONE_USER;
785786

786787
/* rgw::auth::RemoteAuthApplier */
787788
ACLOwner rgw::auth::RemoteApplier::get_aclowner() const
@@ -954,6 +955,7 @@ void rgw::auth::RemoteApplier::write_ops_log_entry(rgw_log_entry& entry) const
954955
if (account) {
955956
entry.account_id = account->id;
956957
}
958+
entry.user = info.keystone_user;
957959
}
958960

959961
/* TODO(rzarzynski): we need to handle display_name changes. */

src/rgw/rgw_auth.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ class RemoteApplier : public IdentityApplier {
590590
const uint32_t acct_type;
591591
const std::string access_key_id;
592592
const std::string subuser;
593+
const std::string keystone_user;
593594

594595
public:
595596
enum class acct_privilege_t {
@@ -599,21 +600,24 @@ class RemoteApplier : public IdentityApplier {
599600

600601
static const std::string NO_SUBUSER;
601602
static const std::string NO_ACCESS_KEY;
603+
static const std::string NO_KEYSTONE_USER;
602604

603605
AuthInfo(const rgw_user& acct_user,
604606
const std::string& acct_name,
605607
const uint32_t perm_mask,
606608
const acct_privilege_t level,
607609
const std::string access_key_id,
608610
const std::string subuser,
611+
const std::string keystone_user,
609612
const uint32_t acct_type=TYPE_NONE)
610613
: acct_user(acct_user),
611614
acct_name(acct_name),
612615
perm_mask(perm_mask),
613616
is_admin(acct_privilege_t::IS_ADMIN_ACCT == level),
614617
acct_type(acct_type),
615618
access_key_id(access_key_id),
616-
subuser(subuser) {
619+
subuser(subuser),
620+
keystone_user(keystone_user) {
617621
}
618622
};
619623

src/rgw/rgw_auth_keystone.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ TokenEngine::get_creds_info(const TokenEngine::token_envelope_t& token
159159
level,
160160
rgw::auth::RemoteApplier::AuthInfo::NO_ACCESS_KEY,
161161
rgw::auth::RemoteApplier::AuthInfo::NO_SUBUSER,
162+
token.get_user_name(),
162163
TYPE_KEYSTONE
163164
};
164165
}
@@ -665,6 +666,7 @@ EC2Engine::get_creds_info(const EC2Engine::token_envelope_t& token,
665666
level,
666667
access_key_id,
667668
rgw::auth::RemoteApplier::AuthInfo::NO_SUBUSER,
669+
token.get_user_name(),
668670
TYPE_KEYSTONE
669671
};
670672
}

src/rgw/rgw_rest_s3.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6749,6 +6749,7 @@ rgw::auth::s3::LDAPEngine::get_creds_info(const rgw::RGWToken& token) const noex
67496749
acct_privilege_t::IS_PLAIN_ACCT,
67506750
rgw::auth::RemoteApplier::AuthInfo::NO_ACCESS_KEY,
67516751
rgw::auth::RemoteApplier::AuthInfo::NO_SUBUSER,
6752+
rgw::auth::RemoteApplier::AuthInfo::NO_KEYSTONE_USER,
67526753
TYPE_LDAP
67536754
};
67546755
}
@@ -6893,6 +6894,7 @@ rgw::auth::s3::STSEngine::get_creds_info(const STS::SessionToken& token) const n
68936894
(token.is_admin) ? acct_privilege_t::IS_ADMIN_ACCT: acct_privilege_t::IS_PLAIN_ACCT,
68946895
token.access_key_id,
68956896
rgw::auth::RemoteApplier::AuthInfo::NO_SUBUSER,
6897+
rgw::auth::RemoteApplier::AuthInfo::NO_KEYSTONE_USER,
68966898
token.acct_type
68976899
};
68986900
}

0 commit comments

Comments
 (0)