Skip to content

Commit

Permalink
Check S3 signer customization insensitively (#2179)
Browse files Browse the repository at this point in the history
* Check S3 signer customization insensitively
* Check EventBridge signer customization insensitively
  • Loading branch information
Steven Yuan authored Jul 7, 2023
1 parent a9c5127 commit 168064f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
21 changes: 10 additions & 11 deletions service/eventbridge/internal/customizations/signer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions service/s3/internal/customizations/signer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 168064f

Please sign in to comment.