From e6e1c49b58a3065aaca70d7189d251e03dbd32ce Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 29 Oct 2021 12:39:34 +0100 Subject: [PATCH] s3: fix shared_credentials_file auth after reverting incorrect fix #5762 Before this change the `shared_credentials_file` config option was being ignored. The correct value is passed into the SDK but it only sets the credentials in the default provider. Unfortunately we wipe the default provider in order to install our own chain if env_auth is true. This patch restores the shared credentials file in the session options, exactly the same as how we restore the profile. Original fix: 1605f9e14dbbe58e s3: Fix shared_credentials_file auth --- backend/s3/s3.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 15f91bcec..653dcfaae 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -1603,6 +1603,10 @@ func s3Connection(ctx context.Context, opt *Options, client *http.Client) (*s3.S awsSessionOpts.SharedConfigState = session.SharedConfigEnable // Set the name of the profile if supplied awsSessionOpts.Profile = opt.Profile + // Set the shared config file if supplied + if opt.SharedCredentialsFile != "" { + awsSessionOpts.SharedConfigFiles = []string{opt.SharedCredentialsFile} + } // The session constructor (aws/session/mergeConfigSrcs) will only use the user's preferred credential source // (from the shared config file) if the passed-in Options.Config.Credentials is nil. awsSessionOpts.Config.Credentials = nil