From 18988b0a469226185368ea7af6cbececad32613d Mon Sep 17 00:00:00 2001 From: Billy Lynch Date: Wed, 29 May 2024 16:45:32 -0400 Subject: [PATCH] Plumb through context to gcpkms signer. --- pkg/gcpkms/gcpkms.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/gcpkms/gcpkms.go b/pkg/gcpkms/gcpkms.go index 1aa5872a..e1584265 100644 --- a/pkg/gcpkms/gcpkms.go +++ b/pkg/gcpkms/gcpkms.go @@ -16,6 +16,7 @@ import ( ) type signingMethodGCP struct { + ctx context.Context client *kms.KeyManagementClient } @@ -24,7 +25,7 @@ func (s *signingMethodGCP) Verify(string, string, interface{}) error { } func (s *signingMethodGCP) Sign(signingString string, ikey interface{}) (string, error) { - ctx := context.Background() + ctx := s.ctx key, ok := ikey.(string) if !ok { @@ -46,12 +47,14 @@ func (s *signingMethodGCP) Alg() string { } type gcpSigner struct { + ctx context.Context client *kms.KeyManagementClient key string } -func New(_ context.Context, client *kms.KeyManagementClient, key string) (ghinstallation.Signer, error) { +func New(ctx context.Context, client *kms.KeyManagementClient, key string) (ghinstallation.Signer, error) { return &gcpSigner{ + ctx: ctx, client: client, key: key, }, nil @@ -60,6 +63,7 @@ func New(_ context.Context, client *kms.KeyManagementClient, key string) (ghinst // Sign signs the JWT claims with the RSA key. func (s *gcpSigner) Sign(claims jwt.Claims) (string, error) { method := &signingMethodGCP{ + ctx: s.ctx, client: s.client, } return jwt.NewWithClaims(method, claims).SignedString(s.key)