-
Notifications
You must be signed in to change notification settings - Fork 382
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): better error messages in signed URLs #11741
feat(storage): better error messages in signed URLs #11741
Conversation
The error messages for signed URL functions (`CreateV2SignedUrl()`, `CreateV4SignedUrl()` and `CreatedSignedPolicyDocument()`) were not helpful when the signing account is missing.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #11741 +/- ##
=======================================
Coverage 93.76% 93.76%
=======================================
Files 1831 1831
Lines 165012 165033 +21
=======================================
+ Hits 154729 154749 +20
- Misses 10283 10284 +1
☔ View full report in Codecov by Sentry. |
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.
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @coryan)
google/cloud/storage/client.cc
line 361 at r1 (raw file):
std::string signing_account_email = SigningEmail(signing_account);
Looks like we should move this after the "sign locally" attempt.
// First try to sign locally.
auto signed_blob = credentials->SignBlob(signing_account, string_to_sign);
if (signed_blob) {
return SignBlobResponseRaw{credentials->KeyId(), *std::move(signed_blob)};
}
// If signing locally fails that may be because the credentials do not
// support signing, or because the signing account is different than the
// credentials account. In either case, try to sign using the API.
std::string signing_account_email = SigningEmail(signing_account);
if (signing_account_email.empty()) {
return google::cloud::internal::InvalidArgumentError(
"signing account cannot be empty."
" The client library was unable to fetch a valid signing email from"
" the configured credentials, and the application did not provide"
" a value in the `google::cloud::storage::SigningAccount` option.",
GCP_ERROR_INFO());
}
internal::SignBlobRequest sign_request(
signing_account_email, internal::Base64Encode(string_to_sign), {});
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.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @dbolduc)
google/cloud/storage/client.cc
line 361 at r1 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
Looks like we should move this after the "sign locally" attempt.
// First try to sign locally. auto signed_blob = credentials->SignBlob(signing_account, string_to_sign); if (signed_blob) { return SignBlobResponseRaw{credentials->KeyId(), *std::move(signed_blob)}; } // If signing locally fails that may be because the credentials do not // support signing, or because the signing account is different than the // credentials account. In either case, try to sign using the API. std::string signing_account_email = SigningEmail(signing_account); if (signing_account_email.empty()) { return google::cloud::internal::InvalidArgumentError( "signing account cannot be empty." " The client library was unable to fetch a valid signing email from" " the configured credentials, and the application did not provide" " a value in the `google::cloud::storage::SigningAccount` option.", GCP_ERROR_INFO()); } internal::SignBlobRequest sign_request( signing_account_email, internal::Base64Encode(string_to_sign), {});
Done.
The error messages for signed URL functions (
CreateV2SignedUrl()
,CreateV4SignedUrl()
andCreatedSignedPolicyDocument()
) were not helpful when the signing account is missing.Fixes #11740
This change is