Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signurl to support path-style bucket access via check_bucket_name_dns_support #1011

Merged
merged 1 commit into from
Mar 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions S3/Crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from . import Config
from logging import debug
from .Utils import encode_to_s3, time_to_epoch, deunicodise, decode_from_s3
from .Utils import encode_to_s3, time_to_epoch, deunicodise, decode_from_s3, check_bucket_name_dns_support
from .SortedDict import SortedDict

import datetime
Expand Down Expand Up @@ -158,7 +158,12 @@ def sign_url_base_v2(**parms):
debug("Signing plaintext: %r", signtext)
parms['sig'] = s3_quote(sign_string_v2(encode_to_s3(signtext)), unicode_output=True)
debug("Urlencoded signature: %s", parms['sig'])
url = "%(proto)s://%(bucket)s.%(host_base)s/%(object)s?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s" % parms
if check_bucket_name_dns_support(Config.Config().host_bucket, parms['bucket']):
url = "%(proto)s://%(bucket)s.%(host_base)s/%(object)s"
else:
url = "%(proto)s://%(host_base)s/%(bucket)s/%(object)s"
url += "?AWSAccessKeyId=%(access_key)s&Expires=%(expiry)d&Signature=%(sig)s"
url = url % parms
if content_disposition:
url += "&response-content-disposition=" + s3_quote(content_disposition, unicode_output=True)
if content_type:
Expand Down