From: Yehuda Sadeh Date: Thu, 19 May 2016 19:52:54 +0000 (-0700) Subject: rgw: don't add port to aws4 canonical string if using default port X-Git-Tag: v11.0.0~355^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=033888bbd0e4d8d81358bf61a099276dddb5692b;p=ceph.git rgw: don't add port to aws4 canonical string if using default port 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 --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 56c74a729f4d..463b4b10603f 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3491,7 +3491,8 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s) map 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); }