summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/ObjectStore/S3ConnectionTrait.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-12-19 11:54:55 +0100
committerRobin Appelman <robin@icewind.nl>2017-12-19 11:54:55 +0100
commit34ced4dd97a9c14975f6c5ff6bc3d6dbe463d64f (patch)
treea6666c1e4b8d34c07aafd3b0c8bf5fab34779102 /lib/private/Files/ObjectStore/S3ConnectionTrait.php
parente550a3ddd8a391a25581302dc87d4877f6c53f0d (diff)
downloadnextcloud-server-34ced4dd97a9c14975f6c5ff6bc3d6dbe463d64f.tar.gz
nextcloud-server-34ced4dd97a9c14975f6c5ff6bc3d6dbe463d64f.zip
add option to use legacy v2 auth with s3
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/ObjectStore/S3ConnectionTrait.php')
-rw-r--r--lib/private/Files/ObjectStore/S3ConnectionTrait.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
index 6556e7b169a..d4910834962 100644
--- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php
+++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
@@ -24,6 +24,7 @@
namespace OC\Files\ObjectStore;
+use Aws\ClientResolver;
use Aws\S3\Exception\S3Exception;
use Aws\S3\S3Client;
@@ -86,11 +87,15 @@ trait S3ConnectionTrait {
],
'endpoint' => $base_url,
'region' => $this->params['region'],
- 'use_path_style_endpoint' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false
+ 'use_path_style_endpoint' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false,
+ 'signature_provider' => \Aws\or_chain([self::class, 'legacySignatureProvider'], ClientResolver::_default_signature_provider())
];
if (isset($this->params['proxy'])) {
$options['request.options'] = ['proxy' => $this->params['proxy']];
}
+ if (isset($this->params['legacy_auth']) && $this->params['legacy_auth']) {
+ $options['signature_version'] = 'v2';
+ }
$this->connection = new S3Client($options);
if (!$this->connection->isBucketDnsCompatible($this->bucket)) {
@@ -120,4 +125,14 @@ trait S3ConnectionTrait {
sleep($this->timeout);
}
}
+
+ public static function legacySignatureProvider($version, $service, $region) {
+ switch ($version) {
+ case 'v2':
+ case 's3':
+ return new S3Signature();
+ default:
+ return null;
+ }
+ }
}