linter fixes

This commit is contained in:
Damodar Lohani
2022-06-29 06:02:20 +00:00
parent fab93f755a
commit 6248225949
4 changed files with 12 additions and 13 deletions
+1 -1
View File
@@ -877,7 +877,7 @@ App::post('/v1/functions/:functionId/executions')
}
}
if(!$current->isEmpty()) {
if (!$current->isEmpty()) {
$jwtObj = new JWT($project->getAttribute('jwtSecrets'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
$jwt = $jwtObj->encode([
'userId' => $user->getId(),
+1 -1
View File
@@ -519,7 +519,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
$fileSecret = OpenSSL::secretString();
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
$tag = null;
$data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $fileSecret, 0, $iv, $tag);
$openSSLCipher = OpenSSL::CIPHER_AES_128_GCM;
+1 -1
View File
@@ -71,7 +71,7 @@ class OpenSSL
*
* @throws \Exception
*/
public static function secretString(int $length = 128):string
public static function secretString(int $length = 128): string
{
return \bin2hex(self::randomPseudoBytes($length));
}
+9 -10
View File
@@ -225,15 +225,14 @@ abstract class Worker
$database = new Database(new MariaDB($register->get('db')), $cache);
$database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
if(!empty($projectId)) {
if (!empty($projectId)) {
$database->setNamespace("_console");
$project = $database->getDocument('projects', $projectId);
if(!$project->isEmpty()) {
if (!$project->isEmpty()) {
$secrets = $project->getAttribute('databaseSecrets');
$filters['encrypt'] = [
'encode' => function($value) use($secrets) {
'encode' => function ($value) use ($secrets) {
$version = array_key_last($secrets);
$key = $secrets[$version];
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
@@ -246,19 +245,19 @@ abstract class Worker
'version' => $version,
]);
},
'decode' => function($value) use($secrets) {
if(is_null($value)) {
'decode' => function ($value) use ($secrets) {
if (is_null($value)) {
return null;
}
$value = json_decode($value, true);
$version = $value['version'];
$key = $secrets[$version];
return OpenSSL::decrypt($value['data'], $value['method'], $key, 0, hex2bin($value['iv']), hex2bin($value['tag']));
}
];
$database = new Database(new MariaDB($register->get('db')), $cache, $filters);
$database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
}