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

Add GCE Signer #50

Open
dhermes opened this issue Oct 24, 2016 · 23 comments
Open

Add GCE Signer #50

dhermes opened this issue Oct 24, 2016 · 23 comments
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Milestone

Comments

@dhermes
Copy link
Contributor

dhermes commented Oct 24, 2016

See: https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob

Relevant history:
googleapis/google-cloud-python#922

@sparhomenko
Copy link

@elibixby In the last update here you mentioned that the implementation is on hold as the GCE/GKE metadata server team plans to add blob signing support. Do you know if they had any progress, or if there is a public ticket for this effort that we can subscribe to?

@theacodes
Copy link
Contributor

Slight update: the ability for the GCE metadata server to sign bytes is planned, but no word on timeline right now.

@elibixby
Copy link

@sparhomenko Sorry about the delay. There was some confusion on the eng team about the use case, but that has now been resolved.

@theacodes
Copy link
Contributor

#108 adds IAM-backed signing which is a temporary workaround until GCE can sign directly.

@ThatsAMorais
Copy link

It appears that IAM-Signer is exactly what I need to sign from a GKE pod; I have token credentials, but don't have access to the private key, and I would like to use the environment's default credentials to accomplish the following.... but it feels like a hack to reach into the SDK like this.

    gcp_client = client.Client()
    credentials = gcp_client._credentials
    credentials.refresh(
        # What request object, and how do I init it with the Session??
    )
    signer = iam.Signer(requests.Request, credentials, credentials.service_account_email)
    string_to_sign = ('{0}\n{1}\n{2}\n{3}\n{4}'.format(
        method, md5, content_type,
        expiration, canonicalized_resource))
    signature = signer.sign(string_to_sign)

I originally tried to use something like this, but the _credentials are a mere token when deployed to GKE. Otherwise, this worked when I specified the GOOGLE_APPLICATION_CREDENTIALS in my local environment as a path to a service account key.

query_params = get_signed_query_params(
        client.Client()._credentials, expiration,
        string_to_sign=string_to_sign)

Am I missing some way to just call google.cloud.storage.sign_this(string_to_sign) (a purely hypothetical method) that just works automatically with the credentials supplied in the environment?

@theacodes
Copy link
Contributor

but it feels like a hack to reach into the SDK like this

It is a bit and it's somewhat intentional. We want you to opt into this because it's non-trivial how it works.

Am I missing some way to just call google.cloud.storage.sign_this(string_to_sign) (a purely hypothetical method) that just works automatically with the credentials supplied in the environment?

This might actually be useful (google.auth.sign) perhaps file a new issue and we'll prioritize it?

@ygbr
Copy link

ygbr commented May 21, 2018

any updates on this? is it possible to sign download URLs using another method or do we still need to use the workaround mentioned above?

@theacodes
Copy link
Contributor

theacodes commented May 21, 2018 via email

@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jun 8, 2018
@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. enhancement triage me I really want to be triaged. labels Jun 11, 2018
@JustinBeckwith JustinBeckwith added the 🚨 This issue needs some love. label Jun 11, 2018
@JustinBeckwith JustinBeckwith removed the 🚨 This issue needs some love. label Jun 25, 2018
@JacobHayes
Copy link
Contributor

I know this package isn't directly related to Google Cloud Functions, but this documentation uses a standard Compute Engine service account (explicitly enabling roles/iam.serviceAccountTokenCreator) from application default credentials to call Blob.generate_signed_url. Testing it out from a cloud function does not work (which is inline with this ticket still being open) and issues:

you need a private key to sign credentials.the credentials you are currently using <class 'google.auth.compute_engine.credentials.Credentials'> just contains a token. see https://google-cloud-python.readthedocs.io/en/latest/core/auth.html?highlight=authentication#setting-up-a-service-account for more details.

It seems the Cloud Function documentation thought google.auth.compute_engine.credentials.Credentials implemented google.auth.credentials.Signing. Could that be reasonably done or should this just be a Cloud Functions documentation fix?

@theacodes
Copy link
Contributor

@JacobHayes probably, can you file a separate bug?

@jezhumble
Copy link

Here's a minimally hacky way to sign blobs with the python client in compute engine and cloud functions: https://gist.github.com/jezhumble/91051485db4462add82045ef9ac2a0ec

@MoSehsah
Copy link

Any Update on this ?

@david-wb
Copy link

david-wb commented Aug 20, 2021

Our team is dealing with this issue now. We're running on Google Cloud-Run where generating signed URLs works just fine with the Nodejs client, but not with the Python client. We would greatly appreciate if this problem was fixed without needing hacky workarounds

@jkevingutierrez
Copy link

jkevingutierrez commented Sep 1, 2021

According to constraints/iam.disableServiceAccountKeyCreation in https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints the export of service account keys is discouraged.

It would be really helpful if this issue could be fixed soon

@Capstan
Copy link

Capstan commented Oct 6, 2021

Is this issue about adding a compute metadata URL to support blob signing directly from workloads and then adapting that into the auth library?

Rather, is there any reason not to just adapt the code to add a specific call to the IAM Credentials API using the provided Auth tokens that already exist in the metadata? Is the expected problem that customers' Workload Identity service accounts might not generally have iam.serviceAccount.signBlob permission via roles/iam.serviceAccountTokenCreator or one of the *Agent roles?

@Capstan
Copy link

Capstan commented Oct 6, 2021

Leaving a breadcrumb for googleapis/google-cloud-python#922, since it was duped to #92 which was then duped to this.

@adriangb
Copy link

Another +1 for this getting resolved as soon as possible, for the many valid reasons stated above. I'll just add that I've done this before in AWS and it was seamless, I was surprised to find out all of the hoops I'm going to have to jump through in GCP 😞 .

@adriangb
Copy link

adriangb commented Apr 18, 2022

So after trying the workaround, there's one big gotcha: there are quota limits on the APIs used by the workaround (6,000 req/min or 60k req/min, I can't tell, ref). So you're limited in how many operations you can make against GCS. Which is not only a deal breaker, but even worse a deal breaker you probably won't find out about until it's too late (which is what happened to us).

@Ark-kun
Copy link

Ark-kun commented Apr 20, 2022

Google is now discouraging exporting the service account keys to files.

I've spent hours and days trying to sign a GCS URL without triggering the security.

This issue is 6 years old. Maybe it's time to fix it?

@salrashid123
Copy link
Contributor

the only way to sign a url in gce, cloud run or cloud functions is to utilize an IAM api's signBlob() . A GCE's metadata server simply has no way to sign arbitrary bytes by itsel

Its a bit awkward to use the iam api but you need to allow a type of "self-impersonation".

i have a small writeup here about this

@jahnagoldman
Copy link

@adriangb what have you done to workaround the quota limits??

just wanted to add another +1 here to get this fixed. it seems like a pretty major issue? i can't really figure out a good workaround since the aforementioned one has quota limits, and the other solution of uploading the service account key seems pretty bad security wise, and gcp specifically calls out never to upload your service account key to cloudrun/gce/or whatever you're using.

any further suggestions / movement on this?? for someone who's using gcp, python and signed urls i don't see a good solution. other than switching to aws or something??

@jahnagoldman
Copy link

@salrashid123 doesn't that solution still use the iam api and therefore is subject to the quota of 6000 or 60000 reqs per minute? doesn't seem like a scalable option?

@astrberg
Copy link

astrberg commented Dec 6, 2023

update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests