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 <steve@cuppett.com>
This commit is contained in:
Stephen Cuppett 2021-06-13 07:12:43 -04:00
parent 68fecc1d9f
commit 4a6a2c2b48

View file

@ -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])
)
);