aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2025-01-29 18:32:49 +0100
committerGitHub <noreply@github.com>2025-01-29 18:32:49 +0100
commit3f45bc5ed3b53a265dc3dd95b10b2506374f6a02 (patch)
treea35bba594ff377b5f810d265bcd24c109aa4a634
parent05008868c7c686517aa208bb8880363d5a59eb8f (diff)
parentf1c025dfd32b795e33369339570d07e550402037 (diff)
downloadnextcloud-server-3f45bc5ed3b53a265dc3dd95b10b2506374f6a02.tar.gz
nextcloud-server-3f45bc5ed3b53a265dc3dd95b10b2506374f6a02.zip
Merge pull request #50514 from nextcloud/feat/s3/sse-c
feat(S3): add SSE-C support in S3 External Storage
-rw-r--r--apps/files_external/lib/Lib/Backend/AmazonS3.php3
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php6
-rw-r--r--lib/private/Files/ObjectStore/S3ConnectionTrait.php2
3 files changed, 7 insertions, 4 deletions
diff --git a/apps/files_external/lib/Lib/Backend/AmazonS3.php b/apps/files_external/lib/Lib/Backend/AmazonS3.php
index e345ed53f70..f71ca40cdfc 100644
--- a/apps/files_external/lib/Lib/Backend/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Backend/AmazonS3.php
@@ -41,6 +41,9 @@ class AmazonS3 extends Backend {
(new DefinitionParameter('useMultipartCopy', $l->t('Enable multipart copy')))
->setType(DefinitionParameter::VALUE_BOOLEAN)
->setDefaultValue(true),
+ (new DefinitionParameter('sse_c_key', $l->t('SSE-C encryption key')))
+ ->setType(DefinitionParameter::VALUE_PASSWORD)
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
->addAuthScheme(AuthMechanism::SCHEME_NULL)
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 03a365fd559..1a866e8c22b 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -113,7 +113,7 @@ class AmazonS3 extends Common {
$this->objectCache[$key] = $this->getConnection()->headObject([
'Bucket' => $this->bucket,
'Key' => $key
- ])->toArray();
+ ] + $this->getSSECParameters())->toArray();
} catch (S3Exception $e) {
if ($e->getStatusCode() >= 500) {
throw $e;
@@ -207,7 +207,7 @@ class AmazonS3 extends Common {
'Key' => $path . '/',
'Body' => '',
'ContentType' => FileInfo::MIMETYPE_FOLDER
- ]);
+ ] + $this->getSSECParameters());
$this->testTimeout();
} catch (S3Exception $e) {
$this->logger->error($e->getMessage(), [
@@ -507,7 +507,7 @@ class AmazonS3 extends Common {
'Body' => '',
'ContentType' => $mimeType,
'MetadataDirective' => 'REPLACE',
- ]);
+ ] + $this->getSSECParameters());
$this->testTimeout();
} catch (S3Exception $e) {
$this->logger->error($e->getMessage(), [
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
index cce8752c360..65fc61ffa77 100644
--- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php
+++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
@@ -213,7 +213,7 @@ trait S3ConnectionTrait {
}
protected function getSSECKey(): ?string {
- if (isset($this->params['sse_c_key'])) {
+ if (isset($this->params['sse_c_key']) && !empty($this->params['sse_c_key'])) {
return $this->params['sse_c_key'];
}