This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
feat(storage): Add cname support for V4 signature #72
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f06d48f
feat(storage): add cname support for v4 signature
HemangChothani ad1afc9
docs(storage): comment changes
HemangChothani 89b4061
Merge remote-tracking branch 'upstream/master' into storage-issue-11
HemangChothani 273f770
feat(storage): address comment
HemangChothani 1c88840
Merge remote-tracking branch 'upstream/master' into storage-issue-11
HemangChothani 4057ae7
feat(storage): doc fix
HemangChothani 7cf7762
Merge branch 'master' into storage-issue-11
frankyn f09a1a8
Merge branch 'master' into storage-issue-11
frankyn 3b96e62
feat(storage): nit addressed
HemangChothani a39064f
Merge remote-tracking branch 'upstream/master' into storage-issue-11
HemangChothani 3f01a04
feat(storage): add conformance tests
HemangChothani f927dc3
Merge branch 'master' into storage-issue-11
frankyn beeae99
Merge branch 'master' into storage-issue-11
frankyn 6af0085
feat(storage): nit
HemangChothani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
|
Contributor
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``. | ||
|
Contributor
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. |
||
|
|
||
|
Contributor
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( | ||
|
Contributor
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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.