-
Notifications
You must be signed in to change notification settings - Fork 116
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
Support id tokens from metadata service #209
base: master
Are you sure you want to change the base?
Conversation
(as a drive-by commentator who would in theory find this useful) Functionality to get an ID token would be welcome, but I don't think this is the right approach. Fundamentally, that What ID tokens and access tokens have in common, is that they care about similar things (e.g. is there a metadata server, vs running on local workstation, or using impersonated credentials, or workforce federation). But both the exact method of getting the token, and the use of them, varies after that. One might also want to get ID tokens that include the service account email, or licensing details (requires extra parameters to get this information). I would prefer that, if implemented, this should be a separate method, e.g. |
I agree that it would be nice to have a better separation between ID tokens and OAuth2 access tokens, but as far as this crate stands today,
Where would you put this method? One of the difficulties I had here was that the actual token-fetching logic is a few layers down from the public API, and I wasn't really sure about the best way of "threading" things through. |
I had a closer look at the support for ID tokens in the library - and it's unfortunate. The So I see why your code is the way it is, as the code is already very fuzzy here, and fixing that would take a much larger rework. Renaming "scope" as "audience" allows you to leverage the existing misunderstandings :) But the larger view is that getting an ID token isn't an authentication flow; it (maybe) uses an already successful authentication flow. If we look at the available methods of getting an ID token (https://cloud.google.com/docs/authentication/get-id-token), we have:
In the second case in particular, we would want a pre-existing So this points to the idea that getting an ID token is layered on top of existing code to get a Google access token, rather than being at the same level. That code could exist in this, or another library (in general, it has been bundled together in the same library, if one looks at examples from other languages). |
This adds support for getting an ID token (as opposed to an oauth2 access token) from Google's metadata service.
Edit: it's a breaking change because it added a field to a public struct. Maybe it's worth marking the option structs as
non_exhaustive
to make such changes less disruptive in the future?