From 4a6a2c2b482e2b34d25d03c9e859078570717a39 Mon Sep 17 00:00:00 2001 From: Stephen Cuppett Date: Sun, 13 Jun 2021 07:12:43 -0400 Subject: [PATCH] Simplify S3ConnectionTrait to defaultProvider plus option When we initially added the EC2 and ECS IAM role support in #24700, we had to use a workaround by explicitly ordering the various providers due to an inconsistency in the AWS SDK for PHP. We submitted a PR there to get that squared away. Now, we've consumed that version upstream for the SDK and can update our code here to be the most concise version as well as position ourselves to pick up new methods as those become available and prevalent in AWS (for acquiring credentials). See also: https://github.com/nextcloud/server/pull/24700#issuecomment-747650892 See also: https://github.com/aws/aws-sdk-php/pull/2172 Signed-off-by: Stephen Cuppett --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index c99ebdbcd5c..6d6d8684153 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -109,15 +109,11 @@ trait S3ConnectionTrait { $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/'; // Adding explicit credential provider to the beginning chain. - // Including environment variables and IAM instance profiles. + // Including default credential provider (skipping AWS shared config files). $provider = CredentialProvider::memoize( CredentialProvider::chain( $this->paramCredentialProvider(), - CredentialProvider::env(), - CredentialProvider::assumeRoleWithWebIdentityCredentialProvider(), - !empty(getenv(EcsCredentialProvider::ENV_URI)) - ? CredentialProvider::ecsCredentials() - : CredentialProvider::instanceProfile() + CredentialProvider::defaultProvider(['use_aws_shared_config_files' => false]) ) );