mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-20 13:23:47 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -5,9 +5,18 @@ use Aws\Kms\KmsClient;
|
|||
|
||||
/**
|
||||
* Uses KMS to supply materials for encrypting and decrypting data.
|
||||
*
|
||||
* Legacy implementation that supports legacy S3EncryptionClient and
|
||||
* S3EncryptionMultipartUploader, which use an older encryption workflow. Use
|
||||
* KmsMaterialsProviderV2 with S3EncryptionClientV2 or
|
||||
* S3EncryptionMultipartUploaderV2 if possible.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class KmsMaterialsProvider extends MaterialsProvider
|
||||
class KmsMaterialsProvider extends MaterialsProvider implements MaterialsProviderInterface
|
||||
{
|
||||
const WRAP_ALGORITHM_NAME = 'kms';
|
||||
|
||||
private $kmsClient;
|
||||
private $kmsKeyId;
|
||||
|
||||
|
@ -28,22 +37,26 @@ class KmsMaterialsProvider extends MaterialsProvider
|
|||
public function fromDecryptionEnvelope(MetadataEnvelope $envelope)
|
||||
{
|
||||
if (empty($envelope[MetadataEnvelope::MATERIALS_DESCRIPTION_HEADER])) {
|
||||
throw new \RuntimeException('Not able to detect kms_cmk_id from an'
|
||||
. ' empty materials description.');
|
||||
throw new \RuntimeException('Not able to detect the materials description.');
|
||||
}
|
||||
|
||||
$materialsDescription = json_decode(
|
||||
$envelope[MetadataEnvelope::MATERIALS_DESCRIPTION_HEADER],
|
||||
true
|
||||
);
|
||||
if (empty($materialsDescription['kms_cmk_id'])) {
|
||||
throw new \RuntimeException('Not able to detect kms_cmk_id from kms'
|
||||
. ' materials description.');
|
||||
|
||||
if (empty($materialsDescription['kms_cmk_id'])
|
||||
&& empty($materialsDescription['aws:x-amz-cek-alg'])) {
|
||||
throw new \RuntimeException('Not able to detect kms_cmk_id (legacy'
|
||||
. ' implementation) or aws:x-amz-cek-alg (current implementation)'
|
||||
. ' from kms materials description.');
|
||||
}
|
||||
|
||||
return new KmsMaterialsProvider(
|
||||
return new self(
|
||||
$this->kmsClient,
|
||||
$materialsDescription['kms_cmk_id']
|
||||
isset($materialsDescription['kms_cmk_id'])
|
||||
? $materialsDescription['kms_cmk_id']
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -60,7 +73,7 @@ class KmsMaterialsProvider extends MaterialsProvider
|
|||
|
||||
public function getWrapAlgorithmName()
|
||||
{
|
||||
return 'kms';
|
||||
return self::WRAP_ALGORITHM_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue