fix: use getPublicKey to retrieve key algorithms#10
Merged
Conversation
ericnorris
reviewed
Mar 25, 2026
Comment on lines
+27
to
+29
| // Use GetPublicKey instead of GetCryptoKeyVersion so that the service account | ||
| // only needs roles/cloudkms.signerVerifier (which includes viewPublicKey) | ||
| // rather than the broader roles/cloudkms.viewer (which includes cryptoKeyVersions.get). |
Collaborator
There was a problem hiding this comment.
nitpick: I don't think we need this comment, since it can live in the commit message. Someone reading this code probably doesn't care whether we use GetPublicKey or GetCryptoKeyVersion, they mainly want to know why we're calling anything at all. I think that is explained by the check below, which makes it clear we are expecting a certain type of key.
ericnorris
reviewed
Mar 25, 2026
| type GoogleKMS struct { | ||
| clientID string | ||
| clientID string | ||
| resourceID string |
Collaborator
There was a problem hiding this comment.
nitpick: maybe kmsResource or kmsKey or anything to better differentiate it from the Client ID?
Future readers probably won't care about the comment and it lives in the commit history anyhow.
ericnorris
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR changes internal/server/github/appkey/google_kms.go to use
GetPublicKeyto retrieve the key's algorithm rather than GetCryptoKeyVersion.Context / Why are we making this change?
GetCryptoKeyVersion returns a bunch of other information in addition to the algorithm. Because of that, it requires that the caller have the broader
cloudkms.cryptoKeyVersions.getpermission. If we useGetPublicKey, it should work with theroles/cloudkms.signerVerifierrole, which is already necessary for the SA to be able to mint tokens using the key.Testing and QA Plan
I built the binary locally and deployed it to the sandbox ESP environment and it at least started the application and it ran.
Impact
We will use
GetPublicKeyto retrieve the key's algorithm, which should result is fewer perms being needed.