Skip to content

Commit

Permalink
fix(expiration): Add expiration back
Browse files Browse the repository at this point in the history
Signed-off-by: dark0dave <dark0dave@mykolab.com>
  • Loading branch information
dark0dave committed Feb 19, 2024
1 parent f06cfdb commit 13655bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/backends/gcloud.rst
Expand Up @@ -219,3 +219,12 @@ Settings
It supports `timedelta`, `datetime`, or `integer` seconds since epoch time.

Note: The maximum value for this option is 7 days (604800 seconds) in version `v4` (See this `Github issue <https://github.com/googleapis/python-storage/issues/456#issuecomment-856884993>`_)

``sa_email`` or ``GS_SA_SIGNING_EMAIL``

default: ``''``

This is the signing email if it is not fetched from the credentials. Or if you wish to sign the signed urls with a different service_account.

As above please note that, Default Google Compute Engine (GCE) Service accounts are
`unable to sign urls <https://googlecloudplatform.github.io/google-cloud-python/latest/storage/blobs.html#google.cloud.storage.blob.Blob.generate_signed_url>`_.
7 changes: 5 additions & 2 deletions storages/backends/gcloud.py
Expand Up @@ -155,7 +155,6 @@ def client(self):
credentials.refresh(requests.Request())
if not hasattr(credentials, "service_account_email"):
credentials.service_account_email = self.sa_email
_LOGGER.debug(f"Signing email: {credentials.service_account_email}")
self.credentials = credentials
if self._client is None:
self._client = Client(project=project_id, credentials=self.credentials)
Expand Down Expand Up @@ -330,9 +329,13 @@ def url(self, name, parameters=None):
quoted_name=_quote(name, safe=b"/~"),
)
elif not self.custom_endpoint:
return blob.generate_signed_url(**self.signed_url_extra())
return blob.generate_signed_url(
expiration=self.expiration,
**self.signed_url_extra()
)
else:
return blob.generate_signed_url(
expiration=self.expiration,
api_access_endpoint=self.custom_endpoint,
**self.signed_url_extra()
)
Expand Down

0 comments on commit 13655bb

Please sign in to comment.