Repository navigation
fix(storage): require a universe domain for IAM signBlob signing - #19383
Draft
shradhakatyal wants to merge 1 commit into
Draft
shradhakatyal wants to merge 1 commit into
shradhakatyal wants to merge 1 commit into
Conversation
`_signing._sign_message` had a default universe domain of `googleapis.com`, and the `generate_signed_url_v2` and `generate_signed_url_v4` helpers passed `None` to it when the caller did not set one. The request URL was then built from a value that the caller never chose. `_sign_message` now takes `universe_domain` as a required argument and raises `ValueError` when it is not a non-empty string. No request is sent in that case. The helpers still accept `universe_domain=None` for credentials that sign locally. `Blob.generate_signed_url` and `Client.generate_signed_post_policy_v4` already pass the universe domain of the client, so their behavior does not change. [Generated-by: AI]
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the URL signing mechanism in google-cloud-storage to require a universe_domain parameter when using an access token and service account email. The _sign_message function has been updated to make universe_domain a required argument and now validates that it is a non-empty string. Corresponding unit tests have been added to verify correct behavior, URL construction, and error handling for invalid or missing universe domains. There are no review comments, and I have no additional feedback to provide.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Signing through the IAM
signBlobAPI now needs an explicit universe domain._signing._sign_messageno longer falls back togoogleapis.com, and it rejects a missing or empty value before it sends a request.Changes
_signing._sign_messagetakesuniverse_domainas a required argument. It raisesValueErrorwhen the value is not a non-empty string, and strips surrounding whitespace._signing.generate_signed_url_v2and_signing.generate_signed_url_v4documentuniverse_domain. They still acceptNonefor credentials that sign locally.Behavior Changes
These apply only to direct callers of the private
_signingmodule.ValueErrorwhenaccess_tokenandservice_account_emailare passed withoutuniverse_domain. Before this change they built a request URL with the hostiamcredentials.None._sign_messagewithoutuniverse_domainraisesTypeError. Before this change it usedgoogleapis.com.Not Changed
Blob.generate_signed_urlandClient.generate_signed_post_policy_v4pass the universe domain of the client, as before.Bucket.generate_signed_urlsigns locally and does not usesignBlob.Testing
_sign_messagecover the request URL for two universe domains, a padded value, and missing, empty, whitespace-only and non-string values._sign_message, thesignBlobrequest URL, access-token signing without a universe domain, and local signing without a universe domain.pytest.mark.parametrize.BEGIN_COMMIT_OVERRIDE
fix(storage): require a universe domain for IAM signBlob signing
END_COMMIT_OVERRIDE