Merge pull request #13623 from appwrite/feat/organization-project-keys-scopes

Add detailed scopes for organization project key management
This commit is contained in:
Matej Bačo authored and GitHub committed 2026-09-11 11:34:19 +02:00
commit dd842bc5a4
10 files changed
+21 -6

No files matched your search

+2
View File
@@ -92,6 +92,8 @@ $admins = [
'projects.write',
'keys.read',
'keys.write',
'organization.projects.keys.read',
'organization.projects.keys.write',
'devKeys.read',
'devKeys.write',
'webhooks.read',
+9
View File
@@ -12,6 +12,15 @@ return [
"Access to create, update, and delete organization projects",
"category" => "Projects",
],
"organization.projects.keys.read" => [
"description" => 'Access to read organization projects\' API keys',
"category" => "Projects",
],
"organization.projects.keys.write" => [
"description" =>
"Access to create, update, and delete organization projects' API keys",
"category" => "Projects",
],
"devKeys.read" => [
"description" => 'Access to read project\'s development keys',
"category" => "Other",
@@ -42,7 +42,7 @@ class Create extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys')
->desc('Create project key')
->groups(['api', 'organization'])
->label('scope', 'keys.write')
->label('scope', ['organization.projects.keys.write', 'keys.write'])
->label('event', 'keys.[keyId].create')
->label('audits.event', 'project.key.create')
->label('audits.resource', 'project.key/{response.$id}')
@@ -33,7 +33,7 @@ class Delete extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys/:keyId')
->desc('Delete project key')
->groups(['api', 'organization'])
->label('scope', 'keys.write')
->label('scope', ['organization.projects.keys.write', 'keys.write'])
->label('event', 'keys.[keyId].delete')
->label('audits.event', 'project.key.delete')
->label('audits.resource', 'project.key/{request.keyId}')
@@ -40,7 +40,7 @@ class Create extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys/ephemeral')
->desc('Create ephemeral project key')
->groups(['api', 'organization'])
->label('scope', 'keys.write')
->label('scope', ['organization.projects.keys.write', 'keys.write'])
->label('event', 'keys.[keyId].create')
->label('audits.event', 'project.key.create')
->label('audits.resource', 'project.key/{response.$id}')
@@ -30,7 +30,7 @@ class Get extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys/:keyId')
->desc('Get project key')
->groups(['api', 'organization'])
->label('scope', 'keys.read')
->label('scope', ['organization.projects.keys.read', 'keys.read'])
->label('sdk', new Method(
namespace: 'organization',
group: 'keys',
@@ -40,7 +40,7 @@ class Update extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys/:keyId')
->desc('Update project key')
->groups(['api', 'organization'])
->label('scope', 'keys.write')
->label('scope', ['organization.projects.keys.write', 'keys.write'])
->label('event', 'keys.[keyId].update')
->label('audits.event', 'project.key.update')
->label('audits.resource', 'project.key/{response.$id}')
@@ -36,7 +36,7 @@ class XList extends Action
->setHttpPath('/v1/organization/projects/:projectId/keys')
->desc('List project keys')
->groups(['api', 'organization'])
->label('scope', 'keys.read')
->label('scope', ['organization.projects.keys.read', 'keys.read'])
->label('sdk', new Method(
namespace: 'organization',
group: 'keys',
@@ -196,6 +196,8 @@ final class ConsoleConsoleClientTest extends Scope
// Well-known scopes must be present
$this->assertContains('projects.read', $scopeIds);
$this->assertContains('projects.write', $scopeIds);
$this->assertContains('organization.projects.keys.read', $scopeIds);
$this->assertContains('organization.projects.keys.write', $scopeIds);
// Every scope has the expected shape
foreach ($response['body']['scopes'] as $scope) {
@@ -93,6 +93,8 @@ final class ConsoleCustomServerTest extends Scope
$scopeIds = \array_column($response['body']['scopes'], '$id');
$this->assertContains('projects.read', $scopeIds);
$this->assertContains('organization.projects.keys.read', $scopeIds);
$this->assertContains('organization.projects.keys.write', $scopeIds);
$projectsRead = null;
foreach ($response['body']['scopes'] as $scope) {