From b317d0d63ddee87892edd26d60141e137cf098b6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 3 May 2024 04:17:42 -0700 Subject: [PATCH] fix: honor S3v2 if configured (#4917) fixes #4915 A regression was introduced in #4755, we hardly test with v2 anymore so this has never been covered. --- cmd/client-s3.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 139c1859..df8d6feb 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -243,16 +243,21 @@ func getCredentialsChainForConfig(config *Config, transport http.RoundTripper) ( credsChain = append(credsChain, credsSts) } - // V4 Credentials - credsV4 := &credentials.Static{ + signType := credentials.SignatureV4 + if strings.EqualFold(config.Signature, "s3v2") { + signType = credentials.SignatureV2 + } + + // Credentials + creds := &credentials.Static{ Value: credentials.Value{ AccessKeyID: config.AccessKey, SecretAccessKey: config.SecretKey, SessionToken: config.SessionToken, - SignerType: credentials.SignatureV4, + SignerType: signType, }, } - credsChain = append(credsChain, credsV4) + credsChain = append(credsChain, creds) return credsChain, nil } @@ -302,24 +307,10 @@ func newFactory() func(config *Config) (Client, *probe.Error) { return nil, err } - // V2 Credentials - credsV2 := &credentials.Static{ - Value: credentials.Value{ - AccessKeyID: config.AccessKey, - SecretAccessKey: config.SecretKey, - SessionToken: "", - SignerType: credentials.SignatureV2, - }, - } - credsChain = append(credsChain, credsV2) - - creds := credentials.NewChainCredentials(credsChain) - - // Not found. Instantiate a new MinIO var e error options := minio.Options{ - Creds: creds, + Creds: credentials.NewChainCredentials(credsChain), Secure: useTLS, Region: env.Get("MC_REGION", env.Get("AWS_REGION", "")), BucketLookup: config.Lookup,