-
Notifications
You must be signed in to change notification settings - Fork 315
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
google-cloud-storage: Cannot create signed url with ImpersonatedCredentials #338
Comments
I just realized there's already an iam signer which could also be used to sign here is the gist for however, the current
The former is preferred way to sign. I would suggest either
(1) is better long term but i i'm not sure of the ramifications of 'just replacing' the underlying api call.. |
heres' an example to and also to get a GoogleIDToken: the usage would be something like source_credentials = service_account.Credentials.from_service_account_file(
'cert.json')
target_scopes = ['https://www.googleapis.com/auth/cloud-platform']
target_credentials = impersonated_credentials.Credentials(
source_credentials = source_credentials,
target_principal='impersonated-account@project.iam.gserviceaccount.com',
target_scopes = target_scopes,
delegates=[],
lifetime=300)
# signer anything you want as the impersonated credentials
b = target_credentials.sign_bytes('badff')
print base64.b64encode(b)
storage_client = storage.Client('fabled-ray-104117', target_credentials)
data_bucket = storage_client.lookup_bucket('fabled-ray-104117')
signed_blob_path = data_bucket.blob("FILENAME")
expires_at_ms = datetime.now() + timedelta(minutes=30)
signed_url = signed_blob_path.generate_signed_url(expires_at_ms, credentials=target_credentials, version="v4")
print signed_url
# ===================== IDToken
target_audience = 'https://myapp-6w42z6vi3q-uc.a.run.app'
id_creds = impersonated_credentials.IDTokenCredentials(
target_credentials, target_audience=target_audience) i've got the code ready but finding some difficulty getting the tests done...i'm also using |
I believe this works now except for this bug on Python3:
The fix, of course, is to decode the bytes returned by
|
* fix: signBytes doesn't work for impersonated credentials Fixes #338 * black
impersonated_credentials cannot create signedURLs for
google-cloud-storage
since it does not require or have the impersonated accounts private key/json file and does not implementcredentials.Signing
that is
yields
Potential solution is to use iamcredentials api once again to 'remotely sign' as in here:
see:
googleapis/google-cloud-java#5043
--
Which means iamcredentials would now look like
i made a working implementation here:
https://gist.github.com/salrashid123/9e3fb4ac87cfa7bbd8b4f6a902aecd00
The text was updated successfully, but these errors were encountered: