From 40fedcbc68df33617b071b59c841f362ac708684 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Sun, 30 Oct 2022 01:47:58 +0000 Subject: [PATCH] Allow no-credentials for S3 Client (#486) * Allow no-credentials for S3 Client * Styling stuff Signed-off-by: Alexandru Busuioc * fix the test pipeline Signed-off-by: Alexandru Busuioc Signed-off-by: Alexandru Busuioc --- .github/workflows/test.yaml | 1 + src/Configuration/ElFinderConfigurationReader.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5275886..2574f6c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,6 +33,7 @@ jobs: - name: 'Install project dependencies' run: | + composer global config --no-plugins allow-plugins.symfony/flex true composer global require --no-progress --no-scripts --no-plugins symfony/flex composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable vendor/bin/simple-phpunit install diff --git a/src/Configuration/ElFinderConfigurationReader.php b/src/Configuration/ElFinderConfigurationReader.php index 582d984..15278df 100644 --- a/src/Configuration/ElFinderConfigurationReader.php +++ b/src/Configuration/ElFinderConfigurationReader.php @@ -232,16 +232,19 @@ private function configureFlysystem($opt, $adapter, $serviceName) break; case 'aws_s3_v3': - $client = new S3Client([ - 'credentials' => [ - 'key' => $opt['aws_s3_v3']['key'], - 'secret' => $opt['aws_s3_v3']['secret'], - ], + $s3Options = [ 'region' => $opt['aws_s3_v3']['region'], 'version' => $opt['aws_s3_v3']['version'], 'endpoint' => $opt['aws_s3_v3']['endpoint'], 'use_path_style_endpoint' => $opt['aws_s3_v3']['use_path_style_endpoint'], - ]); + ]; + if (!empty($opt['aws_s3_v3']['key']) && !empty($opt['aws_s3_v3']['secret'])) { + $s3Options['credentials'] = [ + 'key' => $opt['aws_s3_v3']['key'], + 'secret' => $opt['aws_s3_v3']['secret'], + ]; + } + $client = new S3Client($s3Options); $filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix'], null, null, $opt['aws_s3_v3']['options'])); break;