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 GCS signed urls when using custom endpoint. #837

Closed

Conversation

martey
Copy link
Contributor

@martey martey commented Feb 12, 2020

Fix the generation of signed URLs in Google Cloud Storage when using a custom endpoint (see #648). The previous behavior generates an invalid URL due to the inclusion of the GCS bucket name (e.g. "https://custom_endpoint/bucket_name/filename?signed" instead of "https://custom_endpoint/filename?signed").

Since the "generate_signed_url" method does not natively support custom endpoints, create a signed URL with the standard endpoint and manually replace it (and the bucket name) with the custom endpoint.

Fix the generation of signed URLs in Google Cloud Storage when using a
custom endpoint. The previous behavior generates an invalid URL due to
the inclusion of the GCS bucket name (e.g.
"https://custom_endpoint/bucket_name/filename?signed" instead of
"https://custom_endpoint/filename?signed").

Since the "generate_signed_url" method does not natively support custom
endpoints, create a signed URL with the standard endpoint and manually
replace it (and the bucket name) with the custom endpoint.
@jschneier
Copy link
Owner

Is there a bug on the library about this?

@martey
Copy link
Contributor Author

martey commented Feb 12, 2020

Is there a bug on the library about this?

googleapis/python-storage#11. That issue doesn't have much information, but the same issue on the C++ version of the library (googleapis/google-cloud-cpp#3328) makes it clear that "bucket-bound hostnames" are custom endpoints.

@jschneier
Copy link
Owner

jschneier commented Apr 15, 2020

Looks like this was fixed in the underlying Python library (although with kind of bizarre param names).

Unless I'm misunderstanding the fix.

@martey
Copy link
Contributor Author

martey commented Jun 2, 2020

Sorry for the delay on responding to this.

The change in google-cloud-storage doesn't affect this PR because it is only for v4 signed URLs and custom endpoints currently use v2 signed URLs (see #648 (comment) for more information on why this is). In addition, it only exists in google-cloud-storage >= 1.27.0.

@martey
Copy link
Contributor Author

martey commented Apr 18, 2021

Closing this because I believe my other pull request (see above) is a more elegant solution.

@martey martey closed this Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants