From: Radoslaw Zarzynski Date: Tue, 18 Apr 2017 00:37:57 +0000 (+0200) Subject: rgw: rgw::auth::s3::parse_credentials() extracts access_key_id now. X-Git-Tag: v12.1.0~155^2~43 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4200e126742cb8fde7d89e0f43a2d17f1f12de24;p=ceph.git rgw: rgw::auth::s3::parse_credentials() extracts access_key_id now. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index 81786dc9c171..4afcae3e8035 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -388,16 +388,18 @@ static inline int parse_v4_credentials_hdrs(const req_info& info, /* i } int parse_credentials(const req_info& info, /* in */ - std::string& credential, /* out */ + std::string& access_key_id, /* out */ + std::string& credential_scope, /* out */ std::string& signedheaders, /* out */ std::string& signature, /* out */ std::string& date, /* out */ bool& using_qs) /* out */ { - int ret; const char* const http_auth = info.env->get("HTTP_AUTHORIZATION"); - using_qs = http_auth == nullptr || http_auth[0] == '\0'; + + int ret; + std::string credential; if (using_qs) { ret = parse_v4_credentials_qs(info, credential, signedheaders, signature, date); @@ -422,6 +424,15 @@ int parse_credentials(const req_info& info, /* in */ return -EINVAL; } + /* grab access key id */ + const size_t pos = credential.find("/"); + access_key_id = credential.substr(0, pos); + dout(10) << "access key id = " << access_key_id << dendl; + + /* grab credential scope */ + credential_scope = credential.substr(pos + 1); + dout(10) << "credential scope = " << credential_scope << dendl; + return 0; } diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index 239047d4bf5f..e41c44a3cd9c 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -162,7 +162,8 @@ namespace s3 { int parse_credentials(const req_info& info, /* in */ - std::string& credential, /* out */ + std::string& access_key_id, /* out */ + std::string& credential_scope, /* out */ std::string& signedheaders, /* out */ std::string& signature, /* out */ std::string& date, /* out */ diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 048ea222a2a4..8649f602b85a 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3450,11 +3450,12 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s, bool force_b return -ENOMEM; } - std::string credential; + std::string access_key_id; std::string signed_hdrs; std::string client_signature; int ret = rgw::auth::s3::parse_credentials(s->info, - credential, + access_key_id, + s->aws4_auth->credential_scope, signed_hdrs, client_signature, s->aws4_auth->date, @@ -3463,19 +3464,6 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s, bool force_b return ret; } - /* grab access key id */ - - pos = credential.find("/"); - const std::string access_key_id = credential.substr(0, pos); - - dout(10) << "access key id = " << access_key_id << dendl; - - /* grab credential scope */ - - s->aws4_auth->credential_scope = credential.substr(pos + 1); - - dout(10) << "credential scope = " << s->aws4_auth->credential_scope << dendl; - /* grab user information */ if (rgw_get_user_info_by_access_key(store, access_key_id, *s->user) < 0) {