GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: correctly encode bytes for V2 signature by tritone · Pull Request #382 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Conversation

@tritone

@tritone tritone commented Feb 17, 2021

Copy link
Copy Markdown
Contributor

V2 signature was passing a string to the sign_bytes function
instead of bytes. This works fine for most credentials (since
their sign_bytes implementations accept strings) but not for
impersonated credentials. V4 signature encodes the string before
calling sign_bytes, so I do the same here.

We should also look into clarifying the contract for the
sign_bytes interface in the auth library.

Fixes #373

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tritone
fix: correctly encode bytes for V2 signature
372a4d9
V2 signature was passing a string to the sign_bytes function
instead of bytes. This works fine for most credentials (since
their sign_bytes implementations accept strings) but not for
impersonated credentials. V4 signature encodes the string before
calling sign_bytes, so I do the same here.

We should also look into clarifying the contract for the
sign_bytes interface in the auth library.

Fixes googleapis#373
@tritone
tritone requested review from a team February 17, 2021 03:30
@product-auto-label product-auto-label Bot added the api: storage Issues related to the googleapis/python-storage API. label Feb 17, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 17, 2021
tritone
tritone commented Feb 17, 2021
View reviewed changes
Comment thread google/cloud/storage/_signing.py
"""
ensure_signed_credentials(credentials)
signature_bytes = credentials.sign_bytes(string_to_sign)
signature_bytes = credentials.sign_bytes(string_to_sign.encode("ascii"))

@tritone tritone Feb 17, 2021

Copy link
Copy Markdown
Contributor Author

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.

See https://github.com/googleapis/python-storage/blob/master/google/cloud/storage/_signing.py#L628 for what we do in V4

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tritone
fix py2 failure
6248a14
frankyn
frankyn approved these changes Feb 17, 2021
View reviewed changes

@frankyn frankyn left a comment

Copy link
Copy Markdown
Contributor

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.

Change LGTM.

Opnion: Issue here is that we have multiple sign versions and we focused on v4 more recently.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tritone
Merge branch 'master' into signed-url-fix
7fd92c1
@tritone
tritone merged commit f44212b into googleapis:master Feb 17, 2021
@tritone
tritone deleted the signed-url-fix branch February 17, 2021 19:01
This was referenced Mar 11, 2021
build(deps): bump google-cloud-storage from 1.35.0 to 1.36.2 exesse/mongodump-s3#58
Closed
Bump google-cloud-storage from 1.35.0 to 1.36.2 in /requirements allan-silva/balrog#58
Closed
Bump google-cloud-storage from 1.36.0 to 1.36.2 RasaHQ/rasa#8171
Closed
build(deps): bump google-cloud-storage from 1.35.0 to 1.36.2 in /bot mozilla/code-coverage#829
Merged
build(deps): bump google-cloud-storage from 1.35.0 to 1.36.2 in /backend mozilla/code-coverage#830
Merged
Bump google-cloud-storage from 1.36.0 to 1.36.2 CC-Wolke7/app-microservice#41
Closed
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@tritone @cojenco
fix: correctly encode bytes for V2 signature (googleapis#382)
164efeb
* fix: correctly encode bytes for V2 signature

V2 signature was passing a string to the sign_bytes function
instead of bytes. This works fine for most credentials (since
their sign_bytes implementations accept strings) but not for
impersonated credentials. V4 signature encodes the string before
calling sign_bytes, so I do the same here.

We should also look into clarifying the contract for the
sign_bytes interface in the auth library.

Fixes googleapis#373

* fix py2 failure
cojenco pushed a commit to cojenco/python-storage that referenced this pull request Oct 13, 2021
@tritone @cojenco
fix: correctly encode bytes for V2 signature (googleapis#382)
3a49b9f
* fix: correctly encode bytes for V2 signature

V2 signature was passing a string to the sign_bytes function
instead of bytes. This works fine for most credentials (since
their sign_bytes implementations accept strings) but not for
impersonated credentials. V4 signature encodes the string before
calling sign_bytes, so I do the same here.

We should also look into clarifying the contract for the
sign_bytes interface in the auth library.

Fixes googleapis#373

* fix py2 failure
@release-please release-please Bot mentioned this pull request Jan 12, 2022
chore(main): release 3.0.0 #688
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@frankyn frankyn frankyn approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/python-storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

It's impossible to generate a signed url (v2) with impersonated Credentials

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@tritone @frankyn
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.