Replace defaultProvider with explicit calls to exclude user home directory lookup

Signed-off-by: James Letendre <james.letendre@gmail.com>
This commit is contained in:
James Letendre 2020-12-14 16:20:30 -05:00
parent 85aa77539b
commit 5b756a9fb0
1 changed files with 15 additions and 1 deletions

View File

@ -31,6 +31,7 @@ namespace OC\Files\ObjectStore;
use Aws\ClientResolver;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\EcsCredentialProvider;
use Aws\Credentials\Credentials;
use Aws\Exception\CredentialsException;
use Aws\S3\Exception\S3Exception;
@ -103,10 +104,23 @@ trait S3ConnectionTrait {
$provider = CredentialProvider::memoize(
CredentialProvider::chain(
$this->paramCredentialProvider(),
CredentialProvider::defaultProvider()
CredentialProvider::env(),
CredentialProvider::instanceProfile()
)
);
// If running in an ECS environment, then also include the ECS task role in the chain
if (!empty(getenv(EcsCredentialProvider::ENV_URI))) {
$provider = CredentialProvider::memoize(
CredentialProvider::chain(
$this->paramCredentialProvider(),
CredentialProvider::env(),
CredentialProvider::ecsCredentials(),
CredentialProvider::instanceProfile()
)
);
}
$options = [
'version' => isset($this->params['version']) ? $this->params['version'] : 'latest',
'credentials' => $provider,