From 168064f3c1ddb36004b1c0e2e0bf70954084f5bc Mon Sep 17 00:00:00 2001 From: Steven Yuan Date: Fri, 7 Jul 2023 15:25:06 -0700 Subject: [PATCH] Check S3 signer customization insensitively (#2179) * Check S3 signer customization insensitively * Check EventBridge signer customization insensitively --- .../internal/customizations/signer_wrapper.go | 21 +++++++++---------- .../internal/customizations/signer_wrapper.go | 20 +++++++++--------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/service/eventbridge/internal/customizations/signer_wrapper.go b/service/eventbridge/internal/customizations/signer_wrapper.go index 76877f5889e..6fb237acc73 100644 --- a/service/eventbridge/internal/customizations/signer_wrapper.go +++ b/service/eventbridge/internal/customizations/signer_wrapper.go @@ -3,6 +3,7 @@ package customizations import ( "context" "fmt" + "strings" "github.com/aws/aws-sdk-go-v2/aws" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" @@ -81,9 +82,8 @@ func (s *SignHTTPRequestMiddleware) HandleFinalize(ctx context.Context, in middl ) { // fetch signer type from context signerVersion := GetSignerVersion(ctx) - - switch signerVersion { - case v4a.Version: + // SigV4a + if strings.EqualFold(signerVersion, v4a.Version) { v4aCredentialProvider, ok := s.credentialsProvider.(v4a.CredentialsProvider) if !ok { return out, metadata, fmt.Errorf("invalid credential-provider provided for sigV4a Signer") @@ -95,15 +95,14 @@ func (s *SignHTTPRequestMiddleware) HandleFinalize(ctx context.Context, in middl LogSigning: s.logSigning, }) return mw.HandleFinalize(ctx, in, next) - - default: - mw := v4.NewSignHTTPRequestMiddleware(v4.SignHTTPRequestMiddlewareOptions{ - CredentialsProvider: s.credentialsProvider, - Signer: s.v4Signer, - LogSigning: s.logSigning, - }) - return mw.HandleFinalize(ctx, in, next) } + // SigV4 + mw := v4.NewSignHTTPRequestMiddleware(v4.SignHTTPRequestMiddlewareOptions{ + CredentialsProvider: s.credentialsProvider, + Signer: s.v4Signer, + LogSigning: s.logSigning, + }) + return mw.HandleFinalize(ctx, in, next) } // RegisterSigningMiddleware registers the wrapper signing middleware to the stack. If a signing middleware is already diff --git a/service/s3/internal/customizations/signer_wrapper.go b/service/s3/internal/customizations/signer_wrapper.go index 6689acb8e9e..4408f3e8a2e 100644 --- a/service/s3/internal/customizations/signer_wrapper.go +++ b/service/s3/internal/customizations/signer_wrapper.go @@ -3,6 +3,7 @@ package customizations import ( "context" "fmt" + "strings" "github.com/aws/aws-sdk-go-v2/aws" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" @@ -83,8 +84,8 @@ func (s *SignHTTPRequestMiddleware) HandleFinalize(ctx context.Context, in middl // fetch signer type from context signerVersion := GetSignerVersion(ctx) - switch signerVersion { - case v4a.Version: + // SigV4a + if strings.EqualFold(signerVersion, v4a.Version) { v4aCredentialProvider, ok := s.credentialsProvider.(v4a.CredentialsProvider) if !ok { return out, metadata, fmt.Errorf("invalid credential-provider provided for sigV4a Signer") @@ -96,15 +97,14 @@ func (s *SignHTTPRequestMiddleware) HandleFinalize(ctx context.Context, in middl LogSigning: s.logSigning, }) return mw.HandleFinalize(ctx, in, next) - - default: - mw := v4.NewSignHTTPRequestMiddleware(v4.SignHTTPRequestMiddlewareOptions{ - CredentialsProvider: s.credentialsProvider, - Signer: s.v4Signer, - LogSigning: s.logSigning, - }) - return mw.HandleFinalize(ctx, in, next) } + // SigV4 + mw := v4.NewSignHTTPRequestMiddleware(v4.SignHTTPRequestMiddlewareOptions{ + CredentialsProvider: s.credentialsProvider, + Signer: s.v4Signer, + LogSigning: s.logSigning, + }) + return mw.HandleFinalize(ctx, in, next) } // RegisterSigningMiddleware registers the wrapper signing middleware to the stack. If a signing middleware is already