]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't add port to aws4 canonical string if using default port
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 19 May 2016 19:52:54 +0000 (12:52 -0700)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Tue, 7 Jun 2016 13:17:26 +0000 (18:47 +0530)
Fixes: #15939
When either port 80 is used, or if it's a secure connection and port 443 is used,
and when going through the presigned url auth, don't add the port to the signed
string.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 033888bbd0e4d8d81358bf61a099276dddb5692b)

src/rgw/rgw_rest_s3.cc

index 75269fd5a7effc12b697c6052f1d39e0918e5971..6f4f4f28f10ecd0dd0529a4b36b64f64a3101902 100644 (file)
@@ -3486,7 +3486,8 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s)
   map<string, string> canonical_hdrs_map;
   istringstream sh(s->aws4_auth->signedheaders);
   string token;
-  string port = s->info.env->get("SERVER_PORT");
+  string port = s->info.env->get("SERVER_PORT", "");
+  string secure_port = s->info.env->get("SERVER_PORT_SECURE", "");
 
   while (getline(sh, token, ';')) {
     string token_env = "HTTP_" + token;
@@ -3512,8 +3513,13 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s)
       }
     }
     string token_value = string(t);
-    if (using_qs && (token == "host"))
-      token_value = token_value + ":" + port;
+    if (using_qs && (token == "host")) {
+      if (!port.empty() && port != "80") {
+        token_value = token_value + ":" + port;
+      } else if (!secure_port.empty() && secure_port != "443") {
+        token_value = token_value + ":" + secure_port;
+      }
+    }
     canonical_hdrs_map[token] = rgw_trim_whitespace(token_value);
   }