-
Notifications
You must be signed in to change notification settings - Fork 155
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
feat(storage): Add cname support for V4 signature #72
Changes from 7 commits
f06d48f
ad1afc9
89b4061
273f770
1c88840
4057ae7
7cf7762
f09a1a8
3b96e62
a39064f
3f01a04
f927dc3
beeae99
6af0085
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2355,6 +2355,8 @@ def generate_signed_url( | |
credentials=None, | ||
version=None, | ||
virtual_hosted_style=False, | ||
bucket_bound_host_name=None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use: |
||
host_name_scheme="http", | ||
): | ||
"""Generates a signed URL for this bucket. | ||
|
||
|
@@ -2373,6 +2375,8 @@ def generate_signed_url( | |
amount of time, you can use this method to generate a URL that | ||
is only valid within a certain time period. | ||
|
||
If ``cname`` is set as an argument of :attr:`api_access_endpoint`, ``https`` works only if using a ``CDN``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cname no longer used in method signature should be updated. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an inline example of using |
||
This is particularly useful if you don't want publicly | ||
accessible buckets, but don't want to require users to explicitly | ||
log in. | ||
|
@@ -2422,6 +2426,18 @@ def generate_signed_url( | |
(Optional) If true, then construct the URL relative the bucket's | ||
virtual hostname, e.g., '<bucket-name>.storage.googleapis.com'. | ||
|
||
:type bucket_bound_host_name: str | ||
:param bucket_bound_host_name: | ||
(Optional) If pass, then construct the URL relative to the bucket-bound hostname | ||
as a CNAME. Value cane be a bare or with scheme, e.g., 'example.com ' or http://example.com. | ||
See: https://cloud.google.com/storage/docs/request-endpoints#cname | ||
|
||
:type host_name_scheme: str | ||
:param host_name_scheme: | ||
(Optional) If ``bucket_bound_host_name`` is passed as a bare hostname, use | ||
this value as the scheme. ``https`` will work only when using a CDN. | ||
Defaults to ``"http"``. | ||
|
||
:raises: :exc:`ValueError` when version is invalid. | ||
:raises: :exc:`TypeError` when expiration is not a valid type. | ||
:raises: :exc:`AttributeError` if credentials is not an instance | ||
|
@@ -2440,10 +2456,19 @@ def generate_signed_url( | |
api_access_endpoint = "https://{bucket_name}.storage.googleapis.com".format( | ||
bucket_name=self.name | ||
) | ||
resource = "/" | ||
elif bucket_bound_host_name: | ||
if ":" in bucket_bound_host_name: | ||
api_access_endpoint = bucket_bound_host_name | ||
else: | ||
api_access_endpoint = "{scheme}://{cname}".format( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
scheme=host_name_scheme, cname=bucket_bound_host_name | ||
) | ||
else: | ||
resource = "/{bucket_name}".format(bucket_name=self.name) | ||
|
||
if virtual_hosted_style or bucket_bound_host_name: | ||
resource = "/" | ||
|
||
if credentials is None: | ||
client = self._require_client(client) | ||
credentials = client._credentials | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer scheme here.