mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
linter fixes
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user