Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

ComputeEngine ID Tokens to use metadata server - #347

Closed
salrashid123 wants to merge 18 commits into
googleapis:masterfrom
salrashid123:compute-idtoken
Closed

ComputeEngine ID Tokens to use metadata server#347
salrashid123 wants to merge 18 commits into
googleapis:masterfrom
salrashid123:compute-idtoken

Conversation

@salrashid123

Copy link
Copy Markdown
Contributor

Fixes:

Refactors google.auth.compute_engine implementation to use the metadata server (which is present in GCP's compute implementations (gce, gke*, cloud run, gcf, gae new runtimes)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 10, 2019


class IDTokenCredentials(credentials.Credentials, credentials.Signing):
class IDTokenCredentials(credentials.Credentials):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing Signing breaks the existing interface of this class. Why can't these credentials continue to sign using the IAM API?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but the capability shouldn't be there anyway, IMO. GCE itself doens' thave the capability to sign: it can get access_tokens and even an id_token but not sign arbitrary blobs by itself. IMO the computeCredential object should just reflect its baseline capabilities the underlying provider gives here anyway (in this case, the provider is the metadata service).

The credentials.Signing capability is baked into the existing class as really just a side effect too interms of gettig an IDtoken: if you were using the IAM api, you could 'just get' an id_token directly without signing

Anyway, her'es the biggest problem i see, that in the existing implementation, the singer and sign_bytes was already exposed directly here

    def signer(self):
        return self._signer

    def sign_bytes(self, message):
        return self._signer.sign(message)

I don't think people are using that capability to direct sign via IAM but it is there.


What the existing implementation is doing is basically allowing the GCE to "impersonate itself" and use the IAM API to get an id token and along the way also allow blob signing. I would say if someone wants to sigin via the IAM api, the impersonated_credential object could do that (i'll file a separate PR for something like this later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think people are using that capability to direct sign via IAM but it is there.

This isn't a good enough reason for us to break a 1.0 interface. this will be a breaking change to users and it will cause issues.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, thats not the reason (its just a statement). the reasons are outlined above as well as the ability to sign isn't privilege a GCE instance has.

per offline, we'll can keep the singer capability as well as using the IAM API to do that bit. Getting the ID token will be through the metadta sever per the most recent commit.

Comment thread google/auth/compute_engine/credentials.py Outdated
@salrashid123

Copy link
Copy Markdown
Contributor Author

note, i kept the additional_claims parameter still in though it doens't really serve any function
since its not even something oidc will allow you via the external interface (though i can't say if someday we'd allow oidc w/ custom claims)

    def __init__(self, request, target_audience,
                 token_uri=_DEFAULT_TOKEN_URI,
                 additional_claims=None,
                 service_account_email=None):

i can also add in warning messages to this PR if someone tries to user the signer methods

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jun 17, 2019
@yoshi-automation yoshi-automation removed the 🚨 This issue needs some love. label Jul 3, 2019
@googlebot

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Aug 9, 2019
@salrashid123

Copy link
Copy Markdown
Contributor Author

@googlebot I consent.

@salrashid123
salrashid123 deleted the compute-idtoken branch August 10, 2019 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants