Skip to content

generate_signed_url allows create of urls with expiration greater than 7 days #456

@sww314

Description

@sww314

Environment details

  • OS type and version:
  • Python version: Python 3.8.6
  • pip version: pip 20.3.3
  • google-cloud-storage version: Version: 1.37.1

Steps to reproduce

  1. Generate a signed url with an expiration of more than 7 days in the future
  2. Save it
  3. Wait for 7+ days
  4. Try to access the URL

Code example

    expiration = timedelta(seconds=45*86400)  #45 days
    signed_url = blob.generate_signed_url(
        expiration=expiration,
        service_account_email=service_account_email,
        access_token=credentials.token,
    )

Stack trace

After 7 days accessing the URL will result in this error:

<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
<StringToSign>GET 1629488504 /BUCKET_NAME/inspection-media/DSC00095.JPG</StringToSign>
</Error>

This used to work, but the documentation recently updated here, to include a warning instead of just saying
https://cloud.google.com/storage/docs/access-control/signed-urls-v2

This is a big issue for us. We generate exports of data including spreadsheets. Our customers want the access in these exports to work for more than 7 days.

  • The documentation should be very clear that signed urls are invalid after 7 days with an error message that is not clear. I assume this is because the underlying key has been rotated out.
  • The library should reject expiration dates to far in the future.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions