Skip to content
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

fix(cred): Use in built library instead of forced cred #1340

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dark0dave
Copy link

@dark0dave dark0dave commented Nov 27, 2023

Closes #941

@dark0dave dark0dave changed the title fix(cred): Use inbuilt library instead of forced cred fix(cred): Use in built library instead of forced cred Jan 19, 2024
@dark0dave dark0dave force-pushed the master branch 3 times, most recently from addab9f to 34f4c52 Compare January 19, 2024 21:07
Signed-off-by: dark0dave <dark0dave@mykolab.com>
@dark0dave dark0dave force-pushed the master branch 2 times, most recently from 7bd0625 to c0ff345 Compare January 22, 2024 16:44
Copy link
Owner

@jschneier jschneier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, have a couple questions to start; am interested in getting this in for sure.

storages/backends/gcloud.py Outdated Show resolved Hide resolved
storages/backends/gcloud.py Outdated Show resolved Hide resolved
@jschneier
Copy link
Owner

Please also update the documentation once the design is finalized

@dark0dave
Copy link
Author

Please also update the documentation once the design is finalized

Can do.

@dark0dave
Copy link
Author

@jschneier thank you for taking the time to review this it is much appreciated. We are using my fork in prod and I would prefer to use the mainline package. Is there anything further needed.

Thanks again.

if self.project_id is None:
self.project_id = project_id
credentials.refresh(requests.Request())
if not hasattr(credentials, "service_account_email"):
Copy link
Owner

@jschneier jschneier Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What determines if the hasattr check fails? Also, if it fails is it an error not to set sa_email?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some situations (workload identity) if you try to use the default service account the service account email can be missing. In this situation its best to provide the sa_email so you can sign urls.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you are saying that this must be set in some situation? Can you add that to the documentation.

@dark0dave
Copy link
Author

@jschneier I have updated

@@ -54,7 +54,7 @@ dropbox = [
"dropbox>=7.2.1; python_version<'3.12'",
]
google = [
"google-cloud-storage>=1.27",
"google-cloud-storage>=2.14",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link to why we need to bump this requirement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Buts generally good to bump the library.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s good to bump your application requirements but as a library I’m trying to maintain as much flexibility for users as possible. If we need a new feature then bumping is worthwhile.

A major version bump in particular could induce work and compat issues to users.

storages/backends/gcloud.py Outdated Show resolved Hide resolved
Comment on lines -322 to +337
default_params = {
"bucket_bound_hostname": self.custom_endpoint,
params = {
"service_account_email": self.credentials.service_account_email,
"access_token": self.credentials.token,
"credentials": self.credentials,
"expiration": self.expiration,
"version": "v4",
}
params = parameters or {}

for key, value in default_params.items():
if value and key not in params:
params[key] = value

if self.custom_endpoint:
params["api_access_endpoint"] = self.custom_endpoint
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of changes reverts using the parameters bit of url(). Sorry if there is no test currently covering this.

if self.project_id is None:
self.project_id = project_id
credentials.refresh(requests.Request())
if not hasattr(credentials, "service_account_email"):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you are saying that this must be set in some situation? Can you add that to the documentation.

Signed-off-by: dark0dave <dark0dave@mykolab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signed urls do not work in Cloud Run with django-storages
2 participants