Correct bucket key headers
Signed-off-by: Bernd.Rederlechner@t-systems.com <bernd.rederlechner@t-systems.com>
This commit is contained in:
parent
5809f7a7ac
commit
2805536f7d
|
@ -38,6 +38,7 @@ use GuzzleHttp\Promise;
|
|||
use GuzzleHttp\Promise\RejectedPromise;
|
||||
use OCP\ILogger;
|
||||
|
||||
|
||||
trait S3ConnectionTrait {
|
||||
/** @var array */
|
||||
protected $params;
|
||||
|
@ -60,8 +61,8 @@ trait S3ConnectionTrait {
|
|||
/** @var string */
|
||||
protected $sseKmsKeyId;
|
||||
|
||||
/** @var string */
|
||||
protected $sseKmsBucketKeyId;
|
||||
/** @var bool */
|
||||
protected $sseUseBucketKey;
|
||||
|
||||
protected $test;
|
||||
|
||||
|
@ -84,11 +85,10 @@ trait S3ConnectionTrait {
|
|||
$params['autocreate'] = !isset($params['autocreate']) ? false : $params['autocreate'];
|
||||
|
||||
// this avoid at least the hash lookups for each read/weite operation
|
||||
if (isset($params['ssekmsbucketkeyid'])) {
|
||||
$this->sseKmsBucketKeyId = $params['ssekmsbucketkeyid'];
|
||||
} elseif (isset($params['ssekmskeyid'])) {
|
||||
if (isset($params['ssekmskeyid'])) {
|
||||
$this->sseKmsKeyId = $params['ssekmskeyid'];
|
||||
}
|
||||
$this->sseUseBucketKey = (isset($params['sseusebucketkey'])) ? $params['sseusebucketkey'] : false;
|
||||
|
||||
$this->params = $params;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ trait S3ConnectionTrait {
|
|||
* @return array with encryption parameters
|
||||
*/
|
||||
public function getSseKmsPutParameters(): array {
|
||||
if (!empty($this->sseKmsBucketKeyId)) {
|
||||
if ($this->sseUseBucketKey) {
|
||||
return [
|
||||
'ServerSideEncryption' => 'aws:kms',
|
||||
'BucketKeyEnabled' => true,
|
||||
|
@ -129,8 +129,7 @@ trait S3ConnectionTrait {
|
|||
* @return array with encryption parameters
|
||||
*/
|
||||
public function getSseKmsGetParameters(): array {
|
||||
if (!empty($this->sseKmsBucketKeyId) ||
|
||||
!empty($this->sseKmsKeyId)) {
|
||||
if (($this->sseUseBucketKey) || !empty($this->sseKmsKeyId)) {
|
||||
return [
|
||||
'ServerSideEncryption' => 'aws:kms',
|
||||
];
|
||||
|
@ -139,7 +138,6 @@ trait S3ConnectionTrait {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the required bucket
|
||||
*
|
||||
|
@ -182,7 +180,6 @@ trait S3ConnectionTrait {
|
|||
$encrypt_state = $this->connection->getBucketEncryption([
|
||||
'Bucket' => $this->bucket,
|
||||
]);
|
||||
return;
|
||||
} catch (S3Exception $e) {
|
||||
try {
|
||||
$logger->info('Bucket key for "'.$this->bucket.'" is not set - adding it.', ['app' => 'objectstore']);
|
||||
|
@ -192,8 +189,8 @@ trait S3ConnectionTrait {
|
|||
'Rules' => [
|
||||
[
|
||||
'ApplyServerSideEncryptionByDefault' => [
|
||||
'KMSMasterKeyID' => $this->sseKmsBucketKeyId,
|
||||
'SSEAlgorithm' => 'aws:kms',
|
||||
'KMSMasterKeyID' => $this->sseKmsKeyId,
|
||||
],
|
||||
'BucketKeyEnabled' => true,
|
||||
],
|
||||
|
@ -249,6 +246,7 @@ trait S3ConnectionTrait {
|
|||
'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()),
|
||||
'csm' => false,
|
||||
'debug' => true,
|
||||
];
|
||||
if (isset($this->params['proxy'])) {
|
||||
$options['request.options'] = ['proxy' => $this->params['proxy']];
|
||||
|
@ -268,7 +266,7 @@ trait S3ConnectionTrait {
|
|||
$this->createNewBucket();
|
||||
}
|
||||
|
||||
if ($this->params['autocreate'] && isset($this->params['ssekmsbucketkeyid'])) {
|
||||
if ($this->params['autocreate'] && $this->sseUseBucketKey) {
|
||||
$this->checkOrPutBucketKey();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue