]> 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)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 19 May 2016 21:09:15 +0000 (14:09 -0700)
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>
src/rgw/rgw_rest_s3.cc

index 56c74a729f4d21314cebe4be051447344da41045..463b4b10603f6b72f5aaaeeef032c81b50a4db6d 100644 (file)
@@ -3491,7 +3491,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;
@@ -3517,8 +3518,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);
   }