]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: dissect AWSv4's Canonical URI crafting into a separated function.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 13 Apr 2017 16:32:29 +0000 (18:32 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 7 Jun 2017 10:43:15 +0000 (12:43 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth_s3.h
src/rgw/rgw_rest_s3.cc

index b4a85c016dbc2fd7872ae1c09685d42b8d157976..f81559097497e5b8ee5bb74e0daca34baab7e793 100644 (file)
@@ -159,6 +159,23 @@ namespace rgw {
 namespace auth {
 namespace s3 {
 
+
+static inline std::string get_v4_canonical_uri(const req_info& info) {
+  /* The code should normalize according to RFC 3986 but S3 does NOT do path
+   * normalization that SigV4 typically does. This code follows the same
+   * approach that boto library. See auth.py:canonical_uri(...). */
+
+  std::string canonical_uri = info.request_uri_aws4;
+
+  if (canonical_uri.empty()) {
+    canonical_uri = "/";
+  } else {
+    boost::replace_all(canonical_uri, "+", "%20");
+  }
+
+  return canonical_uri;
+}
+
 std::string hash_string_sha256(const char* data, int len);
 
 std::string get_v4_canonical_request_hash(CephContext* cct,
index 77d8d00a4d80333efaffd6c25e65b926167a2fb0..4541b9f9c23153034ed2cb9e5966a5004761469b 100644 (file)
@@ -3746,21 +3746,9 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s, bool force_b
    */
 
   /* craft canonical uri */
-
-  /* here code should normalize via rfc3986 but S3 does **NOT** do path normalization
-   * that SigV4 typically does. this code follows the same approach that boto library
-   * see auth.py:canonical_uri(...) */
-
-  s->aws4_auth->canonical_uri = s->info.request_uri_aws4;
-
-  if (s->aws4_auth->canonical_uri.empty()) {
-    s->aws4_auth->canonical_uri = "/";
-  } else {
-    boost::replace_all(s->aws4_auth->canonical_uri, "+", "%20");
-  }
+  s->aws4_auth->canonical_uri = rgw::auth::s3::get_v4_canonical_uri(s->info);
 
   /* craft canonical query string */
-
   s->aws4_auth->canonical_qs = s->info.request_params;
 
   if (!s->aws4_auth->canonical_qs.empty()) {