|
|
@@ -39,7 +39,7 @@ import hmac
|
|
|
import os
|
|
|
import posixpath
|
|
|
|
|
|
-from boto.compat import urllib, encodebytes
|
|
|
+from boto.compat import urllib, encodebytes, parse_qs_safe
|
|
|
from boto.auth_handler import AuthHandler
|
|
|
from boto.exception import BotoClientError
|
|
|
|
|
|
@@ -55,9 +55,13 @@ except ImportError:
|
|
|
# by default.
|
|
|
SIGV4_DETECT = [
|
|
|
'.cn-',
|
|
|
- # In eu-central we support both host styles for S3
|
|
|
+ # In eu-central and ap-northeast-2 we support both host styles for S3
|
|
|
'.eu-central',
|
|
|
'-eu-central',
|
|
|
+ '.ap-northeast-2',
|
|
|
+ '-ap-northeast-2',
|
|
|
+ '.ap-south-1',
|
|
|
+ '-ap-south-1'
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -573,7 +577,7 @@ class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler):
|
|
|
# Because some quoting may have already been applied, let's back it out.
|
|
|
unquoted = urllib.parse.unquote(path.path)
|
|
|
# Requote, this time addressing all characters.
|
|
|
- encoded = urllib.parse.quote(unquoted)
|
|
|
+ encoded = urllib.parse.quote(unquoted, safe='/~')
|
|
|
return encoded
|
|
|
|
|
|
def canonical_query_string(self, http_request):
|
|
|
@@ -688,7 +692,7 @@ class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler):
|
|
|
modified_req.params = copy_params
|
|
|
|
|
|
raw_qs = parsed_path.query
|
|
|
- existing_qs = urllib.parse.parse_qs(
|
|
|
+ existing_qs = parse_qs_safe(
|
|
|
raw_qs,
|
|
|
keep_blank_values=True
|
|
|
)
|
|
|
@@ -769,8 +773,8 @@ class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler):
|
|
|
# Add signature to params now that we have it
|
|
|
req.params['X-Amz-Signature'] = signature
|
|
|
|
|
|
- return 'https://%s%s?%s' % (req.host, req.path,
|
|
|
- urllib.parse.urlencode(req.params))
|
|
|
+ return '%s://%s%s?%s' % (req.protocol, req.host, req.path,
|
|
|
+ urllib.parse.urlencode(req.params))
|
|
|
|
|
|
|
|
|
class STSAnonHandler(AuthHandler):
|
|
|
@@ -878,8 +882,8 @@ class QuerySignatureV1AuthHandler(QuerySignatureHelper, AuthHandler):
|
|
|
def _calc_signature(self, params, *args):
|
|
|
boto.log.debug('using _calc_signature_1')
|
|
|
hmac = self._get_hmac()
|
|
|
- keys = params.keys()
|
|
|
- keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
|
|
|
+ keys = list(params.keys())
|
|
|
+ keys.sort(key=lambda x: x.lower())
|
|
|
pairs = []
|
|
|
for key in keys:
|
|
|
hmac.update(key.encode('utf-8'))
|