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

Added support for access tokens in gcpkms #1358

Conversation

christoffer-eide
Copy link

This PR adds support for access token (via the GOOGLE_CREDENTIALS env var).

If the env var GOOGLE_CREDENTIALS is not set, the gcloud sdk fetches an access token from the instance metadata endpoint http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token.

In our workload on GKE, we don't want to use the access token returned by the metadata endpoint directly. We use this access token to impersonate another service account, which has the minimum of permissions required for the kms decrypt.

There is no facility to set access tokens in sops, only static (long lived) credentials via the credentials file/GOOGLE_CREDENTIALS.

@christoffer-eide christoffer-eide force-pushed the add-support-for-gcp-kms-access-tokens branch 2 times, most recently from 797ef4f to 26f3545 Compare November 25, 2023 20:59
@devstein devstein requested a review from a team November 26, 2023 01:26
@devstein devstein added keyservice/gcpkms go Pull requests that update Go code labels Nov 26, 2023
@christoffer-eide christoffer-eide force-pushed the add-support-for-gcp-kms-access-tokens branch from 7a7136f to ec9a4a7 Compare December 17, 2023 19:30
Copy link
Contributor

@devstein devstein left a comment

Choose a reason for hiding this comment

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

Thanks for contributing @christoffer-eide 🥇

Looks good to me. Can you quickly fix the merge conflicts?

cc @getsops/maintainers if anyone else wants to take a look

@devstein devstein requested a review from a team December 29, 2023 22:08
Copy link
Contributor

@devstein devstein left a comment

Choose a reason for hiding this comment

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

(Meant to comment, not approve yet)

Copy link
Contributor

@devstein devstein left a comment

Choose a reason for hiding this comment

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

Can you add a note to the GCP KMS docs for others to discover this feature?

@devstein
Copy link
Contributor

Hey @christoffer-eide 👋 - someone else just opened a PR #1578 for the same functionality.

Are you able to address the comments, so we can get this merged?

@christoffer-eide christoffer-eide force-pushed the add-support-for-gcp-kms-access-tokens branch from ec9a4a7 to 6c23bb9 Compare August 19, 2024 08:53
Signed-off-by: Christoffer Eide <christoffer.eide@tv2.no>
Signed-off-by: Christoffer Eide <christoffer.eide@tv2.no>
@christoffer-eide christoffer-eide force-pushed the add-support-for-gcp-kms-access-tokens branch from 6c23bb9 to 242b218 Compare August 19, 2024 09:02
@christoffer-eide
Copy link
Author

I'm so sorry, I completely forgot about this 😱

Regarding the proposed change in #1578, it would make it more convenient to have a separate env var for setting the access token.

It would interact better with the gcloud cli,

CLOUDSDK_AUTH_ACCESS_TOKEN ="$(gcloud auth print-access-token)"

vs

GOOGLE_CREDENTIALS ="$(gcloud auth print-access-token --format json | jq '{"access_token": .token}')"

If you think that #1578 is a better solution, this PR can be closed without merging.

@devstein
Copy link
Contributor

All good @christoffer-eide! I agree that using a separate env var CLOUDSDK_AUTH_ACCESS_TOKEN, which is the same behavior as the GCP libraries, makes more sense.

Appreciate the contribution!

Closing in favor of #1578

@devstein devstein closed this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code keyservice/gcpkms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants