Skip to content

fix: use getPublicKey to retrieve key algorithms#10

Merged
simpsonw merged 3 commits into
mainfrom
simpsonw.getPublicKey
Mar 25, 2026
Merged

fix: use getPublicKey to retrieve key algorithms#10
simpsonw merged 3 commits into
mainfrom
simpsonw.getPublicKey

Conversation

@simpsonw
Copy link
Copy Markdown
Member

@simpsonw simpsonw commented Mar 25, 2026

Description

This PR changes internal/server/github/appkey/google_kms.go to use GetPublicKey to 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.get permission. If we use GetPublicKey, it should work with the roles/cloudkms.signerVerifier role, 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 GetPublicKey to retrieve the key's algorithm, which should result is fewer perms being needed.

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).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

type GoogleKMS struct {
clientID string
clientID string
resourceID string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick: maybe kmsResource or kmsKey or anything to better differentiate it from the Client ID?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Future readers probably won't care about the comment and it lives in the commit
history anyhow.
@simpsonw simpsonw merged commit fab64bb into main Mar 25, 2026
2 checks passed
@simpsonw simpsonw deleted the simpsonw.getPublicKey branch March 25, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants