From 9ad1917072df15ced1b50336d7d73917da279351 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 7 Aug 2021 15:49:36 +0300 Subject: [PATCH] Permission fix --- app/views/console/functions/function.phtml | 2 +- app/workers/database.php | 4 ++++ src/Appwrite/Utopia/Response/Model/Func.php | 12 ++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml index 405fd28eb0..0ec16db908 100644 --- a/app/views/console/functions/function.phtml +++ b/app/views/console/functions/function.phtml @@ -452,7 +452,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled', true); - +
Add * for wildcard access
diff --git a/app/workers/database.php b/app/workers/database.php index 42df89e1b5..60c060ee7a 100644 --- a/app/workers/database.php +++ b/app/workers/database.php @@ -3,6 +3,7 @@ use Appwrite\Resque\Worker; use Utopia\CLI\Console; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; require_once __DIR__.'/../workers.php'; @@ -21,6 +22,8 @@ class DatabaseV1 extends Worker { $projectId = $this->args['projectId'] ?? ''; $type = $this->args['type'] ?? ''; + + Authorization::disable(); switch (strval($type)) { case CREATE_TYPE_ATTRIBUTE: @@ -49,6 +52,7 @@ class DatabaseV1 extends Worker break; } + Authorization::reset(); } public function shutdown(): void diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 6d5bf8c01a..6c1ba151f6 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -16,12 +16,12 @@ class Func extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('$permissions', [ - 'type' => Response::MODEL_PERMISSIONS, - 'description' => 'Function permissions.', - 'default' => new \stdClass, - 'example' => new \stdClass, - 'array' => false, + ->addRule('execute', [ + 'type' => self::TYPE_STRING, + 'description' => 'Document execute permissions.', + 'default' => '', + 'example' => 'role:all', + 'array' => true, ]) ->addRule('name', [ 'type' => self::TYPE_STRING,