-
-
Notifications
You must be signed in to change notification settings - Fork 866
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: Generate Signed Urls through a service account by providing service_account_email and access_token #1427
base: master
Are you sure you want to change the base?
Conversation
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.
One main comment about token freshness.
We also should add at least one test.
The note about authentication is helpful but I'm wondering if it needs to be more deeply integrated into the docs rather than a separate note.
Forgot to say, this looks great! Minimal and clear. |
I adjusted some existing tests that were failing due to error Default Creds missing by mocking _client. I will do some additional tests for the feature add plus a credentials test when I get time. The test you set up |
…only explicilty passed in setting
Curious why you've decided to go in the new direction? The last set of changes seemed easier to understand but I am likely missing some context. |
@jschneier the previous set of changes was easier to understand but we would be forcing all envs that had the service account email to start signing using the IAM Sign Blob API. That API has a rate limit. Thats why I was thinking maybe it is better to make this a setting that has to be provided so we don't break any large service that potentially has a service account email in the env but is signing with a private key file. Signing with a key file in the env doesn't cause an extra API call, so we should probably keep that as is and only use the sign blob API if required.
|
Thanks, that makes sense, need to digest a bit. |
This looks good to me. I also agree with the decision of adding a separate config |
I agree that this direction looks good, just have a few more questions before we merge it in. |
Sounds good, definitely missing a few tests. We will bump the minimum required Google SDK library with this so you can remove the version mention. |
@jschneier I have added some tests around the new settings initialization and also tests around the generate_signed_url calls with this new branch of code |
Thanks, the code for this looks very good. I think we should reword the authentication docs a bit before merging. My concern is that there is a very large blob of text discussing the limitation and for the mitigation the django-storages settings is mixed in with discussion of kwargs for Can you explain here what the requirements are, it sounds like setting Given that there are now multiple ways to authenticate it also might make sense to make sub-sections so the delineation is more clear. EDIT: Can we also fix the linter? |
@jschneier I have made the changes requested. Let me know what you think |
Make black happy
@jschneier Just checking to remind you like you said in the README : ). No worries if busy |
@jschneier would you mind taking a look at this? Getting this working would be lovely :) |
fixes #941
sa_email
setting in order to set the service_account_email used for signing URL if service_account key file not available in the env. Compute services (Cloud Run, Cloud Function, App Engine, Compute Engine ...) don't have access to the key file but get access tokens through the metadata server. Passing service_account_email and access_token will cause generate_signed_url to use the IAM API to signBlob using the provided service account email and token.