mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Added new roles for execution
This commit is contained in:
@@ -24,6 +24,8 @@ $logged = [
|
||||
'projects.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
];
|
||||
|
||||
$admins = [
|
||||
@@ -37,8 +39,6 @@ $admins = [
|
||||
'users.write',
|
||||
'collections.read',
|
||||
'collections.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'platforms.read',
|
||||
'platforms.write',
|
||||
'keys.read',
|
||||
@@ -50,6 +50,10 @@ $admins = [
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
];
|
||||
|
||||
return [
|
||||
@@ -63,6 +67,8 @@ return [
|
||||
'files.read',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
],
|
||||
],
|
||||
ROLE_MEMBER => [
|
||||
|
||||
@@ -13,6 +13,8 @@ return [ // List of publicly visible scopes
|
||||
'files.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'health.read',
|
||||
// 'platforms.read',
|
||||
// 'platforms.write',
|
||||
|
||||
@@ -618,7 +618,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
||||
App::post('/v1/functions/:functionId/executions')
|
||||
->groups(['api', 'functions'])
|
||||
->desc('Create Execution')
|
||||
->label('scope', 'functions.write')
|
||||
->label('scope', 'execution.write')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'createExecution')
|
||||
@@ -654,16 +654,20 @@ App::post('/v1/functions/:functionId/executions')
|
||||
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
|
||||
}
|
||||
|
||||
Authorization::reset();
|
||||
|
||||
$validator = new Authorization($function, 'execute');
|
||||
|
||||
if (!$validator->isValid($function->getPermissions())) { // Check if user has write access to execute function
|
||||
throw new Exception($validator->getDescription(), 401);
|
||||
}
|
||||
|
||||
Authorization::disable();
|
||||
|
||||
$execution = $projectDB->createDocument([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
|
||||
'$permissions' => [
|
||||
'read' => $function->getPermissions(),
|
||||
'read' => $function->getPermissions()['execute'] ?? [],
|
||||
'write' => [],
|
||||
],
|
||||
'dateCreated' => time(),
|
||||
@@ -698,7 +702,7 @@ App::post('/v1/functions/:functionId/executions')
|
||||
App::get('/v1/functions/:functionId/executions')
|
||||
->groups(['api', 'functions'])
|
||||
->desc('List Executions')
|
||||
->label('scope', 'functions.read')
|
||||
->label('scope', 'execution.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'listExecutions')
|
||||
@@ -740,7 +744,7 @@ App::get('/v1/functions/:functionId/executions')
|
||||
App::get('/v1/functions/:functionId/executions/:executionId')
|
||||
->groups(['api', 'functions'])
|
||||
->desc('Get Execution')
|
||||
->label('scope', 'functions.read')
|
||||
->label('scope', 'execution.read')
|
||||
->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'getExecution')
|
||||
|
||||
@@ -75,6 +75,8 @@ trait ProjectCustom
|
||||
'files.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
|
||||
@@ -680,6 +680,7 @@ class FunctionsCustomServerTest extends Scope
|
||||
]);
|
||||
|
||||
$executionId = $execution['body']['$id'] ?? '';
|
||||
|
||||
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||
|
||||
sleep(15);
|
||||
|
||||
Reference in New Issue
Block a user