]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw::auth::s3::parse_credentials() extracts access_key_id now.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 18 Apr 2017 00:37:57 +0000 (02:37 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 7 Jun 2017 10:43:17 +0000 (12:43 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth_s3.cc
src/rgw/rgw_auth_s3.h
src/rgw/rgw_rest_s3.cc

index 81786dc9c17176dc805480cb95681a35e8f3205b..4afcae3e8035d94bbaf65d509cae6f0cc217f122 100644 (file)
@@ -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;
 }
 
index 239047d4bf5fa0b9bfd2bc2afc2f386b28221af8..e41c44a3cd9cffd6255d55514619ad8389269022 100644 (file)
@@ -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 */
index 048ea222a2a4c2ea98a1d15e521b021fbea0dc87..8649f602b85aea9c502c6749cb3905c8547554ed 100644 (file)
@@ -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) {