You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding ability to sign URL from Compute Engine Service account #922
Creating a signed URL for a cloud storage blob. With a normal service account (and key), this is done with crypto from the key. On App Engine, the signing functionality is surface via app_identity.sign_blob() (as mentioned above).
If you don't already have a service account and json/p12 key, you can create a new one then generate .p12 or .json file.
Copy it to your compute engine
You can use classmethod from_service_account_p12 or classmethod from_service_account_json respectively and copy it to your compute engine directory. For the email parameter in the classmethod from_service_account_p12 you will use the service account email that you've generated the key from. You will include the link to the file in either of the classmethod parameters.
You then have to assign read-only or ownership to whatever file/directory you're trying to access in the cloud storage browser or through command line
You will then have to establish the bucket (if you're only working within one bucket) with gcloud.storage.bucket.Bucket(name='BucketName')
UPDATE: I should make it more clear that I really appreciate the attempt to help out 👍
@julienmarcbrown Thanks for the comment but it's missing the point of this issue. (Note that I'm the author of this issue and of the methods you suggest using.)
This question is about GCE service accounts. These are service accounts attached to a GCE instance and they provide methods (as I mention above) via the GCE metadata server:
This would be really helpful to have. To create/modify objects we can just auth with oauth2client.client.GoogleCredentials.get_application_default on any environment. But to get signed urls, we need to also have a .p12 which is incredibly inconvenient.
Not particularly, but I was hoping to avoid busing around key files when we can already do so much with oauth2client.client.GoogleCredentials from get_application_default. It seems odd to be able to delete objects, make them public, etc but not be able to make a temporary access url. I understand the technical differences between the token we get with oauth and an actual private key, just seems like there would be a way without requiring private keys.
What are the benefit of the JSON service account key?
The JSON service account key uses the PEM format, which is much simpler than PKCS12. Google essentially recommends that you use a JSON key.
The reason the signed URL differs from the access token is that it is generated completely on the client, using the private key to sign some content. This signed content is used directly from the signed URL:
Yeah, the client side generation is convenient (aside from being cryptographically sound and easy to verify), but makes it much less flexible IMO.
For example, it makes it much more inconvenient to test applications that use signed urls from local boxes since it requires developers to have the private key (as opposed to just running gcloud auth login). And obviously doesn't work out of the box on GCE. If it was provided as an endpoint of some sort, it would be trivial to run in any environment and instead rely on authorization to make that request instead of having the private key.
It seems strange to me to offer this in gcloud-python since it involves 0 interaction with the API. Is it in-scope for the library to handle non-API user-convenience scenarios?
You're just referring to the signing of bytes rather than the generation of the signed URL as a library feature?
Assuming the answer is yes, the reason we worry about it here is because
it isn't supported in oauth2client
our issue tracker is the only surface area for some people when asked questions for Google
Anyhow, the question still stands. Using GCE service accounts seems to be a recommended practice for interacting with Google APIs, but AFAIK there is no way to sign content with these (to contrast, there are equivalents for GAE).
I figured you'd have a pulse on whether or not something was in the works. Or if folks were even aware that GCE service accounts aren't as usable as service accounts on GAE or from a JSON key file.
Activity
dhermes commentedon Jun 16, 2015
This is the extent of what the metadata server can do
dhermes commentedon Jun 24, 2015
@jgeewax Is there anyone other than @ludoch that might know if a GCE equivalent of
app_identity.sign_blob()exists?jgeewax commentedon Jun 25, 2015
@ajessup ?
ajessup commentedon Jun 25, 2015
What's the use-case?
dhermes commentedon Jun 25, 2015
Creating a signed URL for a cloud storage blob. With a normal service account (and key), this is done with crypto from the key. On App Engine, the signing functionality is surface via
app_identity.sign_blob()(as mentioned above).julienmarcbrown commentedon Jul 14, 2015
To use GCE and Cloud storage
from_service_account_p12or classmethod from_service_account_jsonrespectively and copy it to your compute engine directory. For theemailparameter in the classmethodfrom_service_account_p12you will use the service account email that you've generated the key from. You will include the link to the file in either of the classmethod parameters.gcloud.storage.bucket.Bucket(name='BucketName')I wrote this kind of fast, I'm not sure if i've missed anything.
dhermes commentedon Jul 14, 2015
UPDATE: I should make it more clear that I really appreciate the attempt to help out 👍
@julienmarcbrown Thanks for the comment but it's missing the point of this issue. (Note that I'm the author of this issue and of the methods you suggest using.)
This question is about GCE service accounts. These are service accounts attached to a GCE instance and they provide methods (as I mention above) via the GCE metadata server:
JacobHayes commentedon Jan 27, 2016
This would be really helpful to have. To create/modify objects we can just auth with
oauth2client.client.GoogleCredentials.get_application_defaulton any environment. But to get signed urls, we need to also have a.p12which is incredibly inconvenient.Has there been any progress on this?
dhermes commentedon Jan 27, 2016
I don't think there are any plans for implementing this with Compute Engine service accounts.
As for
.p12, is there a reason you aren't using a JSON service account key?JacobHayes commentedon Jan 27, 2016
Not particularly, but I was hoping to avoid busing around key files when we can already do so much with
oauth2client.client.GoogleCredentialsfromget_application_default. It seems odd to be able to delete objects, make them public, etc but not be able to make a temporary access url. I understand the technical differences between the token we get with oauth and an actual private key, just seems like there would be a way without requiring private keys.What are the benefit of the JSON service account key?
dhermes commentedon Jan 27, 2016
The JSON service account key uses the PEM format, which is much simpler than PKCS12. Google essentially recommends that you use a JSON key.
The reason the signed URL differs from the access token is that it is generated completely on the client, using the private key to sign some content. This signed content is used directly from the signed URL:
@thobrla Any thoughts?
JacobHayes commentedon Jan 27, 2016
Yeah, the client side generation is convenient (aside from being cryptographically sound and easy to verify), but makes it much less flexible IMO.
For example, it makes it much more inconvenient to test applications that use signed urls from local boxes since it requires developers to have the private key (as opposed to just running
gcloud auth login). And obviously doesn't work out of the box on GCE. If it was provided as an endpoint of some sort, it would be trivial to run in any environment and instead rely on authorization to make that request instead of having the private key.thobrla commentedon Jan 29, 2016
It seems strange to me to offer this in gcloud-python since it involves 0 interaction with the API. Is it in-scope for the library to handle non-API user-convenience scenarios?
dhermes commentedon Jan 29, 2016
You're just referring to the signing of bytes rather than the generation of the signed URL as a library feature?
Assuming the answer is yes, the reason we worry about it here is because
oauth2clientAnyhow, the question still stands. Using GCE service accounts seems to be a recommended practice for interacting with Google APIs, but AFAIK there is no way to sign content with these (to contrast, there are equivalents for GAE).
I figured you'd have a pulse on whether or not something was in the works. Or if folks were even aware that GCE service accounts aren't as usable as service accounts on GAE or from a JSON key file.
5 remaining items
chore: move samples from python-docs-sample (#66)
chore: move samples from python-docs-sample (#45)
chore(deps): update all dependencies (#922)
chore(deps): update all dependencies (#922)
docs: add samples from bigtable (#38)
chore: Update .repo-metadata.json and CODEOWNERS (#922)
chore: release 0.50.0 (#922)
chore: bump urllib3 from 1.26.12 to 1.26.18 (#922)
chore: move samples from python-docs-sample (#18)
samples: add samples from pubsub/cloud-client (#134)
Auto-update dependencies. [(#922)](GoogleCloudPlatform/python-docs-sa…
docs: add samples from spanner/cloud-client (#117)
chore(main): release 3.30.0 (#922)