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

IAM: support STS token source #750

Open
aylei opened this issue Nov 13, 2020 · 7 comments
Open

IAM: support STS token source #750

aylei opened this issue Nov 13, 2020 · 7 comments
Assignees
Labels
api: iam Issues related to the Identity and Access Management API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@aylei
Copy link

aylei commented Nov 13, 2020

When using workload identity federation, one follows the steps described in Accessing resources from an OIDC identity provider:

  1. Get a token from the OIDC provider
  2. Exchange the token for a federated access token through the STS API
  3. Impersonate a service account via the federated access token

It would be valuable if the SDK can provide an implementation of TokenSource to simplify the step 2. Generally, the newly introduced stsTokenSource will take a TokenSource of the token from an external OIDC provider, and exchange/refresh federated access tokens from STS.

@product-auto-label product-auto-label bot added the api: iam Issues related to the Identity and Access Management API. label Nov 13, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Nov 13, 2020
@tbpg tbpg added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Nov 17, 2020
@tbpg
Copy link
Contributor

tbpg commented Nov 17, 2020

Thanks for the feature request. We have some work in progress to improve the auth experience, but don't have an ETA on this specific idea.

@codyoss
Copy link
Member

codyoss commented Aug 9, 2021

This should now be supported by the underlying oauth2 package: https://pkg.go.dev/golang.org/x/oauth2/google#hdr-Workload_Identity_Federation

@codyoss codyoss closed this as completed Aug 9, 2021
@apstndb
Copy link

apstndb commented Aug 10, 2021

golang.org/x/oauth2/google supports external_account typed JSON credentials(golang/oauth2#462) but underlying golang.org/x/oauth2/google/internal/externalaccount is not exported.
I think this PR should be re-opened for more general oauth2.TokenSource like STSTokenSource.

@codyoss
Copy link
Member

codyoss commented Aug 10, 2021

That package should not need to be exported. Methods like CredentialsFromJSON will now do the right thing if the type is an "external_account".

@apstndb
Copy link

apstndb commented Aug 11, 2021

external_account type credentials which is supported by CredentialsFromJSON is not flexible because it processes STS subject token only from file path or URL.
https://github.com/golang/oauth2/blob/faf39c7919d5800bdcad2fbcb2a330c3fdd0ef96/google/google.go#L100-L126
https://github.com/golang/oauth2/blob/faf39c7919d5800bdcad2fbcb2a330c3fdd0ef96/google/internal/externalaccount/basecredentials.go#L87-L101

  1. Get a token from the OIDC provider
  2. Exchange the token for a federated access token through the STS API
  3. Impersonate a service account via the federated access token

It would be valuable if the SDK can provide an implementation of TokenSource to simplify the step 2.

I don't know this repo(google-api-go-client) is the right place of the token source but I think the original feature request means to exchange OIDC token from a string variable or another token source.

@codyoss codyoss reopened this Aug 11, 2021
@codyoss
Copy link
Member

codyoss commented Aug 11, 2021

CredentialsFromJSON is not flexible because it processes STS subject token only from file path or URL.

Could you provide some psudocode for how you would envision working with with such an api. I am not quite understanding how the current implementation does not provide enough flexibility for what you are trying to accomplish.

@apstndb
Copy link

apstndb commented Aug 13, 2021

I have written PoC code. golang.org/x/oauth2/google package doesn't support that use-case.
https://github.com/apstndb/image-pull-secret-controller/blob/ae414e44a30ebdef331d59a5dc32d9a27af84feb/controllers/imagepullsecret_controller.go#L95-L115
I have used Kubernetes TokenRequest API(it can be replaced by Service Account Token Volume Projection sometimes) but I think there are more situations which receive OIDC token dynamically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: iam Issues related to the Identity and Access Management API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants