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

Application Default Credentials and Workload Identity Federation can't sign URLs #10

Open
thclark opened this issue Apr 13, 2022 · 2 comments
Assignees
Labels
devops System admin and devops performance If you want to run cool, you've got to run on heavy, heavy fuel security A security-related feature tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now)

Comments

@thclark
Copy link
Contributor

thclark commented Apr 13, 2022

Bug report

What is the current behavior?

If using ADCs or WIF, it's not possible to sign URLs because there's no local private key, only a token. So, whether on Cloud Run, Locally, or in a GitHub runner, you have to have the full Service Account JSON key in order to generate signed blobs for storage.

I came across this first in testing a django app, using WIF for authenticating github actions instead of injecting a service account into the runner. But, it will apply anywhere that a django server using django-gcp (or django-storages) is using WIF for authentication.

I believe the same problem will appear when impersonating a service account, since inspecting the credentials generated for that, there doesn't seem to be a key either.

What is the expected behavior?

Be able to sign URLs when operating under WIF

Possible Solution #1

Catch the exception as it happens, and handle it with an extra API call to signBlob as described here.

There may be pathological performance edge cases, however, since this potentially leads to N api requests when iterating a queryset of records containing files - so there needs to be some careful treatment of that; or a documented process (eg method call) to sign all of a queryset at once, which is slightly different from the usual django pattern of doing it.

Possible Solution #2

relevant (same problem): https://stackoverflow.com/questions/64234214/how-to-generate-a-blob-signed-url-in-google-cloud-run

Workaround

Presently, the simple solution is to use Service Account Credentials for all projects that need to do this.

@thclark thclark self-assigned this Apr 13, 2022
@thclark thclark added devops System admin and devops performance If you want to run cool, you've got to run on heavy, heavy fuel security A security-related feature tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now) labels Apr 13, 2022
@thclark thclark moved this to Priority 1 (Low) in Octue Board Apr 13, 2022
@thclark
Copy link
Contributor Author

thclark commented Apr 13, 2022

Also note that this isn't caught by the existing storage test cases; the mocks are too close to the code. Some actual integration tests would slow things down substantially but be of great benefit.

@thclark thclark changed the title Workload Identity Federation can't sign URLs Application Default Credentials and Workload Identity Federation can't sign URLs Nov 10, 2022
@thclark thclark moved this from Priority 1 (Low) to Priority 2 (Medium) in Octue Board Nov 10, 2022
@thclark
Copy link
Contributor Author

thclark commented Nov 16, 2022

Possibly of relevance: octue/octue-sdk-python#429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops System admin and devops performance If you want to run cool, you've got to run on heavy, heavy fuel security A security-related feature tech-debt Technical debt (tidy up, refactoring, restructuring, caused by laziness now)
Projects
Status: Priority 2 (Medium)
Development

No branches or pull requests

1 participant