mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
formatting
This commit is contained in:
+5
-5
@@ -381,11 +381,11 @@ Database::addFilter(
|
||||
|
||||
Database::addFilter(
|
||||
'masterEncrypt',
|
||||
function(mixed $value, Document $document, Database $database) {
|
||||
function (mixed $value, Document $document, Database $database) {
|
||||
$keyId = $document->getAttribute('keyId', '');
|
||||
$database->setNamespace('_console');
|
||||
$key = Authorization::skip(fn() => $database->getDocument('secrets', $keyId));
|
||||
if($key->isEmpty()) {
|
||||
if ($key->isEmpty()) {
|
||||
throw new Exception("Unable to find master key with ID ($keyId} to encrypt.");
|
||||
}
|
||||
|
||||
@@ -400,15 +400,15 @@ Database::addFilter(
|
||||
'version' => $keyId,
|
||||
]);
|
||||
},
|
||||
function(mixed $value, Document $document, Database $database) {
|
||||
if(is_null($value)) {
|
||||
function (mixed $value, Document $document, Database $database) {
|
||||
if (is_null($value)) {
|
||||
return null;
|
||||
}
|
||||
$value = json_decode($value, true);
|
||||
$keyId = $value['version'];
|
||||
$database->setNamespace('_console');
|
||||
$key = Authorization::skip(fn() => $database->getDocument('secrets', $keyId));
|
||||
if($key->isEmpty()) {
|
||||
if ($key->isEmpty()) {
|
||||
throw new Exception("Unable to find master key with ID {$keyId} to decrypt.");
|
||||
}
|
||||
$secret = $key->getAttribute('secret');
|
||||
|
||||
@@ -148,7 +148,6 @@ $cli
|
||||
} else {
|
||||
Console::info("[{$time}] No projects for key rotation.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// # of days in seconds (1 day = 86400s)
|
||||
|
||||
@@ -28,7 +28,7 @@ class EncryptionV1 extends Worker
|
||||
{
|
||||
$type = $this->args['type'] ?? '';
|
||||
|
||||
switch($type) {
|
||||
switch ($type) {
|
||||
case APP_ENCRYPTION_TYPE_PROJECT_MASTER_KEY:
|
||||
$project = new Document($this->args['project'] ?? []);
|
||||
$this->rotateMasterKeyForProject($project);
|
||||
@@ -50,10 +50,12 @@ class EncryptionV1 extends Worker
|
||||
'$collection' => 'secrets',
|
||||
'secret' => OpenSSL::secretString(),
|
||||
])));
|
||||
$dbForConsole->updateDocument('projects', $projectId,
|
||||
$dbForConsole->updateDocument(
|
||||
'projects',
|
||||
$projectId,
|
||||
$project
|
||||
->setAttribute('keyId', $secret->getId())
|
||||
->setAttribute('keyRotationDate', time() + App::getEnv('_APP_KEY_ROTATION_INTERVAL', 60 * 60 * 24 * 90))
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user