diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 942f886417..70374b5331 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -439,7 +439,7 @@ App::post('/v1/databases') ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].create') ->label('scope', 'databases.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'database.create') ->label('audits.resource', 'database/{response.$id}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -517,7 +517,7 @@ App::get('/v1/databases') ->desc('List databases') ->groups(['api', 'database']) ->label('scope', 'databases.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'list') @@ -578,7 +578,7 @@ App::get('/v1/databases/:databaseId') ->desc('Get database') ->groups(['api', 'database']) ->label('scope', 'databases.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'get') @@ -604,7 +604,7 @@ App::get('/v1/databases/:databaseId/logs') ->desc('List database logs') ->groups(['api', 'database']) ->label('scope', 'databases.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listLogs') @@ -696,7 +696,7 @@ App::put('/v1/databases/:databaseId') ->desc('Update database') ->groups(['api', 'database', 'schema']) ->label('scope', 'databases.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].update') ->label('audits.event', 'database.update') ->label('audits.resource', 'database/{response.$id}') @@ -735,7 +735,7 @@ App::delete('/v1/databases/:databaseId') ->desc('Delete database') ->groups(['api', 'database', 'schema']) ->label('scope', 'databases.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].delete') ->label('audits.event', 'database.delete') ->label('audits.resource', 'database/{request.databaseId}') @@ -785,7 +785,7 @@ App::post('/v1/databases/:databaseId/collections') ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'collection.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{response.$id}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -853,7 +853,7 @@ App::get('/v1/databases/:databaseId/collections') ->desc('List collections') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listCollections') @@ -923,7 +923,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId') ->desc('Get collection') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getCollection') @@ -958,7 +958,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') ->desc('List collection logs') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listCollectionLogs') @@ -1059,7 +1059,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId') ->desc('Update collection') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].update') ->label('audits.event', 'collection.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -1123,7 +1123,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId') ->desc('Delete collection') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].delete') ->label('audits.event', 'collection.delete') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -1180,7 +1180,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -1238,7 +1238,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/email' ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1281,7 +1281,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/enum') ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1329,7 +1329,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/ip') ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1372,7 +1372,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/url') ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1415,7 +1415,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/intege ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1487,7 +1487,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/float' ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1562,7 +1562,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/boolea ->groups(['api', 'database', 'schema']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1604,7 +1604,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/dateti ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1649,7 +1649,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/relati ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.namespace', 'databases') @@ -1777,7 +1777,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/attributes') ->desc('List attributes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listAttributes') @@ -1861,7 +1861,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/attributes/:key') ->desc('Get attribute') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getAttribute') @@ -1936,7 +1936,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/strin ->desc('Update string attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -1980,7 +1980,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/email ->desc('Update email attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2022,7 +2022,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/enum/ ->desc('Update enum attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2066,7 +2066,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/ip/:k ->desc('Update IP address attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2108,7 +2108,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/url/: ->desc('Update URL attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2150,7 +2150,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/integ ->desc('Update integer attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2202,7 +2202,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/float ->desc('Update float attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2254,7 +2254,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/boole ->desc('Update boolean attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2295,7 +2295,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/datet ->desc('Update dateTime attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2336,7 +2336,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/attributes/:key/ ->desc('Update relationship attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2394,7 +2394,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/attributes/:key ->desc('Delete attribute') ->groups(['api', 'database', 'schema']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update') ->label('audits.event', 'attribute.delete') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2509,7 +2509,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes') ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].indexes.[indexId].create') ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'index.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -2679,7 +2679,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes') ->desc('List indexes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listIndexes') @@ -2755,7 +2755,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') ->desc('Get index') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getIndex') @@ -2795,7 +2795,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') ->desc('Delete index') ->groups(['api', 'database']) ->label('scope', 'collections.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].indexes.[indexId].update') ->label('audits.event', 'index.delete') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') @@ -2861,7 +2861,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].create') ->label('scope', 'documents.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'document.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}') @@ -3113,7 +3113,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') ->desc('List documents') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listDocuments') @@ -3275,7 +3275,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen ->desc('Get document') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getDocument') @@ -3368,7 +3368,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen ->desc('List document logs') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'listDocumentLogs') @@ -3474,7 +3474,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum ->groups(['api', 'database']) ->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].update') ->label('scope', 'documents.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'document.update') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}') ->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}') @@ -3710,7 +3710,7 @@ App::delete('/v1/databases/:databaseId/collections/:collectionId/documents/:docu ->desc('Delete document') ->groups(['api', 'database']) ->label('scope', 'documents.write') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].delete') ->label('audits.event', 'document.delete') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{request.documentId}') @@ -3825,7 +3825,7 @@ App::get('/v1/databases/usage') ->desc('Get databases usage stats') ->groups(['api', 'database', 'usage']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getUsage') @@ -3907,7 +3907,7 @@ App::get('/v1/databases/:databaseId/usage') ->desc('Get database usage stats') ->groups(['api', 'database', 'usage']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getDatabaseUsage') @@ -3995,7 +3995,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/usage') ->desc('Get collection usage stats') ->groups(['api', 'database', 'usage']) ->label('scope', 'collections.read') - ->label('resourceType', 'databases') + ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'databases') ->label('sdk.method', 'getCollectionUsage') diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7de443625e..290eed8651 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -138,7 +138,7 @@ App::post('/v1/functions') ->desc('Create function') ->label('scope', 'functions.write') ->label('event', 'functions.[functionId].create') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('audits.event', 'function.create') ->label('audits.resource', 'function/{response.$id}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -401,7 +401,7 @@ App::get('/v1/functions') ->groups(['api', 'functions']) ->desc('List functions') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'list') @@ -462,7 +462,7 @@ App::get('/v1/functions/runtimes') ->groups(['api', 'functions']) ->desc('List runtimes') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listRuntimes') @@ -496,7 +496,7 @@ App::get('/v1/functions/specifications') ->groups(['api', 'functions']) ->desc('List available function runtime specifications') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listSpecifications') @@ -533,7 +533,7 @@ App::get('/v1/functions/:functionId') ->groups(['api', 'functions']) ->desc('Get function') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'get') @@ -558,7 +558,7 @@ App::get('/v1/functions/:functionId/usage') ->desc('Get function usage') ->groups(['api', 'functions', 'usage']) ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getFunctionUsage') @@ -663,7 +663,7 @@ App::get('/v1/functions/usage') ->desc('Get functions usage') ->groups(['api', 'functions']) ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getUsage') @@ -763,7 +763,7 @@ App::put('/v1/functions/:functionId') ->groups(['api', 'functions']) ->desc('Update function') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].update') ->label('audits.event', 'function.update') ->label('audits.resource', 'function/{response.$id}') @@ -966,7 +966,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId/download') ->groups(['api', 'functions']) ->desc('Download deployment') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getDeploymentDownload') @@ -1052,7 +1052,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId') ->groups(['api', 'functions']) ->desc('Update deployment') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].deployments.[deploymentId].update') ->label('audits.event', 'deployment.update') ->label('audits.resource', 'function/{request.functionId}') @@ -1115,7 +1115,7 @@ App::delete('/v1/functions/:functionId') ->groups(['api', 'functions']) ->desc('Delete function') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].delete') ->label('audits.event', 'function.delete') ->label('audits.resource', 'function/{request.functionId}') @@ -1163,7 +1163,7 @@ App::post('/v1/functions/:functionId/deployments') ->groups(['api', 'functions']) ->desc('Create deployment') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].deployments.[deploymentId].create') ->label('audits.event', 'deployment.create') ->label('audits.resource', 'function/{request.functionId}') @@ -1383,7 +1383,7 @@ App::get('/v1/functions/:functionId/deployments') ->groups(['api', 'functions']) ->desc('List deployments') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listDeployments') @@ -1467,7 +1467,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId') ->groups(['api', 'functions']) ->desc('Get deployment') ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getDeployment') @@ -1511,7 +1511,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId') ->groups(['api', 'functions']) ->desc('Delete deployment') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].deployments.[deploymentId].delete') ->label('audits.event', 'deployment.delete') ->label('audits.resource', 'function/{request.functionId}') @@ -1577,7 +1577,7 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/build') ->groups(['api', 'functions']) ->desc('Rebuild deployment') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].deployments.[deploymentId].update') ->label('audits.event', 'deployment.update') ->label('audits.resource', 'function/{request.functionId}') @@ -1646,7 +1646,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId/build') ->groups(['api', 'functions']) ->desc('Cancel deployment') ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('audits.event', 'deployment.update') ->label('audits.resource', 'function/{request.functionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -1736,9 +1736,9 @@ App::post('/v1/functions/:functionId/executions') ->groups(['api', 'functions']) ->desc('Create execution') ->label('scope', 'execution.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].executions.[executionId].create') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'createExecution') @@ -2140,7 +2140,7 @@ App::get('/v1/functions/:functionId/executions') ->groups(['api', 'functions']) ->desc('List executions') ->label('scope', 'execution.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listExecutions') @@ -2228,7 +2228,7 @@ App::get('/v1/functions/:functionId/executions/:executionId') ->groups(['api', 'functions']) ->desc('Get execution') ->label('scope', 'execution.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getExecution') @@ -2276,7 +2276,7 @@ App::delete('/v1/functions/:functionId/executions/:executionId') ->groups(['api', 'functions']) ->desc('Delete execution') ->label('scope', 'execution.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('event', 'functions.[functionId].executions.[executionId].delete') ->label('audits.event', 'executions.delete') ->label('audits.resource', 'function/{request.functionId}') @@ -2347,7 +2347,7 @@ App::post('/v1/functions/:functionId/variables') ->desc('Create variable') ->groups(['api', 'functions']) ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('audits.event', 'variable.create') ->label('audits.resource', 'function/{request.functionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -2412,7 +2412,7 @@ App::get('/v1/functions/:functionId/variables') ->desc('List variables') ->groups(['api', 'functions']) ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listVariables') @@ -2440,7 +2440,7 @@ App::get('/v1/functions/:functionId/variables/:variableId') ->desc('Get variable') ->groups(['api', 'functions']) ->label('scope', 'functions.read') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getVariable') @@ -2480,7 +2480,7 @@ App::put('/v1/functions/:functionId/variables/:variableId') ->desc('Update variable') ->groups(['api', 'functions']) ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('audits.event', 'variable.update') ->label('audits.resource', 'function/{request.functionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -2542,7 +2542,7 @@ App::delete('/v1/functions/:functionId/variables/:variableId') ->desc('Delete variable') ->groups(['api', 'functions']) ->label('scope', 'functions.write') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('audits.event', 'variable.delete') ->label('audits.resource', 'function/{request.functionId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) @@ -2591,7 +2591,7 @@ App::get('/v1/functions/templates') ->groups(['api']) ->desc('List function templates') ->label('scope', 'public') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'listTemplates') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) @@ -2629,7 +2629,7 @@ App::get('/v1/functions/templates') App::get('/v1/functions/templates/:templateId') ->desc('Get function template') ->label('scope', 'public') - ->label('resourceType', 'functions') + ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'getTemplate') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 50fd30420e..e4a627d027 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -56,7 +56,7 @@ App::post('/v1/messaging/providers/mailgun') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createMailgunProvider') @@ -144,7 +144,7 @@ App::post('/v1/messaging/providers/sendgrid') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createSendgridProvider') @@ -220,7 +220,7 @@ App::post('/v1/messaging/providers/smtp') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createSmtpProvider') @@ -308,7 +308,7 @@ App::post('/v1/messaging/providers/msg91') ->label('audits.event', 'provider.create') ->label('audits.resource', 'provider/{response.$id}') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('event', 'providers.[providerId].create') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') @@ -386,7 +386,7 @@ App::post('/v1/messaging/providers/telesign') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createTelesignProvider') @@ -464,7 +464,7 @@ App::post('/v1/messaging/providers/textmagic') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createTextmagicProvider') @@ -542,7 +542,7 @@ App::post('/v1/messaging/providers/twilio') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createTwilioProvider') @@ -620,7 +620,7 @@ App::post('/v1/messaging/providers/vonage') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createVonageProvider') @@ -698,7 +698,7 @@ App::post('/v1/messaging/providers/fcm') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createFcmProvider') @@ -762,7 +762,7 @@ App::post('/v1/messaging/providers/apns') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].create') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createApnsProvider') @@ -846,7 +846,7 @@ App::get('/v1/messaging/providers') ->desc('List providers') ->groups(['api', 'messaging']) ->label('scope', 'providers.read') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listProviders') @@ -903,7 +903,7 @@ App::get('/v1/messaging/providers/:providerId/logs') ->desc('List provider logs') ->groups(['api', 'messaging']) ->label('scope', 'providers.read') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listProviderLogs') @@ -992,7 +992,7 @@ App::get('/v1/messaging/providers/:providerId') ->desc('Get provider') ->groups(['api', 'messaging']) ->label('scope', 'providers.read') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'getProvider') @@ -1020,7 +1020,7 @@ App::patch('/v1/messaging/providers/mailgun/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateMailgunProvider') @@ -1127,7 +1127,7 @@ App::patch('/v1/messaging/providers/sendgrid/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateSendgridProvider') @@ -1219,7 +1219,7 @@ App::patch('/v1/messaging/providers/smtp/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateSmtpProvider') @@ -1342,7 +1342,7 @@ App::patch('/v1/messaging/providers/msg91/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateMsg91Provider') @@ -1423,7 +1423,7 @@ App::patch('/v1/messaging/providers/telesign/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateTelesignProvider') @@ -1506,7 +1506,7 @@ App::patch('/v1/messaging/providers/textmagic/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateTextmagicProvider') @@ -1589,7 +1589,7 @@ App::patch('/v1/messaging/providers/twilio/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateTwilioProvider') @@ -1672,7 +1672,7 @@ App::patch('/v1/messaging/providers/vonage/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateVonageProvider') @@ -1755,7 +1755,7 @@ App::patch('/v1/messaging/providers/fcm/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateFcmProvider') @@ -1825,7 +1825,7 @@ App::patch('/v1/messaging/providers/apns/:providerId') ->label('audits.resource', 'provider/{response.$id}') ->label('event', 'providers.[providerId].update') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateApnsProvider') @@ -1921,7 +1921,7 @@ App::delete('/v1/messaging/providers/:providerId') ->label('audits.resource', 'provider/{request.$providerId}') ->label('event', 'providers.[providerId].delete') ->label('scope', 'providers.write') - ->label('resourceType', 'providers') + ->label('resourceType', RESOURCE_TYPE_PROVIDERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'deleteProvider') @@ -1957,7 +1957,7 @@ App::post('/v1/messaging/topics') ->label('audits.resource', 'topic/{response.$id}') ->label('event', 'topics.[topicId].create') ->label('scope', 'topics.write') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createTopic') @@ -1998,7 +1998,7 @@ App::get('/v1/messaging/topics') ->desc('List topics') ->groups(['api', 'messaging']) ->label('scope', 'topics.read') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listTopics') @@ -2055,7 +2055,7 @@ App::get('/v1/messaging/topics/:topicId/logs') ->desc('List topic logs') ->groups(['api', 'messaging']) ->label('scope', 'topics.read') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listTopicLogs') @@ -2145,7 +2145,7 @@ App::get('/v1/messaging/topics/:topicId') ->desc('Get topic') ->groups(['api', 'messaging']) ->label('scope', 'topics.read') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'getTopic') @@ -2174,7 +2174,7 @@ App::patch('/v1/messaging/topics/:topicId') ->label('audits.resource', 'topic/{response.$id}') ->label('event', 'topics.[topicId].update') ->label('scope', 'topics.write') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateTopic') @@ -2219,7 +2219,7 @@ App::delete('/v1/messaging/topics/:topicId') ->label('audits.resource', 'topic/{request.$topicId}') ->label('event', 'topics.[topicId].delete') ->label('scope', 'topics.write') - ->label('resourceType', 'topics') + ->label('resourceType', RESOURCE_TYPE_TOPICS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'deleteTopic') @@ -2260,7 +2260,7 @@ App::post('/v1/messaging/topics/:topicId/subscribers') ->label('audits.resource', 'subscriber/{response.$id}') ->label('event', 'topics.[topicId].subscribers.[subscriberId].create') ->label('scope', 'subscribers.write') - ->label('resourceType', 'subscribers') + ->label('resourceType', RESOURCE_TYPE_SUBSCRIBERS) ->label('sdk.auth', [APP_AUTH_TYPE_JWT, APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createSubscriber') @@ -2354,7 +2354,7 @@ App::get('/v1/messaging/topics/:topicId/subscribers') ->desc('List subscribers') ->groups(['api', 'messaging']) ->label('scope', 'subscribers.read') - ->label('resourceType', 'subscribers') + ->label('resourceType', RESOURCE_TYPE_SUBSCRIBERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listSubscribers') @@ -2434,7 +2434,7 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') ->desc('List subscriber logs') ->groups(['api', 'messaging']) ->label('scope', 'subscribers.read') - ->label('resourceType', 'subscribers') + ->label('resourceType', RESOURCE_TYPE_SUBSCRIBERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listSubscriberLogs') @@ -2524,7 +2524,7 @@ App::get('/v1/messaging/topics/:topicId/subscribers/:subscriberId') ->desc('Get subscriber') ->groups(['api', 'messaging']) ->label('scope', 'subscribers.read') - ->label('resourceType', 'subscribers') + ->label('resourceType', RESOURCE_TYPE_SUBSCRIBERS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'getSubscriber') @@ -2567,7 +2567,7 @@ App::delete('/v1/messaging/topics/:topicId/subscribers/:subscriberId') ->label('audits.resource', 'subscriber/{request.$subscriberId}') ->label('event', 'topics.[topicId].subscribers.[subscriberId].delete') ->label('scope', 'subscribers.write') - ->label('resourceType', 'subscribers') + ->label('resourceType', RESOURCE_TYPE_SUBSCRIBERS) ->label('sdk.auth', [APP_AUTH_TYPE_JWT, APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'deleteSubscriber') @@ -2627,7 +2627,7 @@ App::post('/v1/messaging/messages/email') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].create') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createEmail') @@ -2780,7 +2780,7 @@ App::post('/v1/messaging/messages/sms') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].create') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createSms') @@ -2897,7 +2897,7 @@ App::post('/v1/messaging/messages/push') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].create') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'createPush') @@ -3071,7 +3071,7 @@ App::get('/v1/messaging/messages') ->desc('List messages') ->groups(['api', 'messaging']) ->label('scope', 'messages.read') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listMessages') @@ -3128,7 +3128,7 @@ App::get('/v1/messaging/messages/:messageId/logs') ->desc('List message logs') ->groups(['api', 'messaging']) ->label('scope', 'messages.read') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listMessageLogs') @@ -3218,7 +3218,7 @@ App::get('/v1/messaging/messages/:messageId/targets') ->desc('List message targets') ->groups(['api', 'messaging']) ->label('scope', 'messages.read') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'listTargets') @@ -3289,7 +3289,7 @@ App::get('/v1/messaging/messages/:messageId') ->desc('Get message') ->groups(['api', 'messaging']) ->label('scope', 'messages.read') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'getMessage') @@ -3317,7 +3317,7 @@ App::patch('/v1/messaging/messages/email/:messageId') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].update') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateEmail') @@ -3518,7 +3518,7 @@ App::patch('/v1/messaging/messages/sms/:messageId') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].update') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updateSms') @@ -3674,7 +3674,7 @@ App::patch('/v1/messaging/messages/push/:messageId') ->label('audits.resource', 'message/{response.$id}') ->label('event', 'messages.[messageId].update') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'updatePush') @@ -3913,7 +3913,7 @@ App::delete('/v1/messaging/messages/:messageId') ->label('audits.resource', 'message/{request.messageId}') ->label('event', 'messages.[messageId].delete') ->label('scope', 'messages.write') - ->label('resourceType', 'messages') + ->label('resourceType', RESOURCE_TYPE_MESSAGES) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN, APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'messaging') ->label('sdk.method', 'delete') diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index afd3c4687a..23dd21c173 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -49,7 +49,7 @@ App::post('/v1/storage/buckets') ->desc('Create bucket') ->groups(['api', 'storage']) ->label('scope', 'buckets.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('event', 'buckets.[bucketId].create') ->label('audits.event', 'bucket.create') ->label('audits.resource', 'bucket/{response.$id}') @@ -148,7 +148,7 @@ App::get('/v1/storage/buckets') ->desc('List buckets') ->groups(['api', 'storage']) ->label('scope', 'buckets.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'listBuckets') @@ -209,7 +209,7 @@ App::get('/v1/storage/buckets/:bucketId') ->desc('Get bucket') ->groups(['api', 'storage']) ->label('scope', 'buckets.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getBucket') @@ -235,7 +235,7 @@ App::put('/v1/storage/buckets/:bucketId') ->desc('Update bucket') ->groups(['api', 'storage']) ->label('scope', 'buckets.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('event', 'buckets.[bucketId].update') ->label('audits.event', 'bucket.update') ->label('audits.resource', 'bucket/{response.$id}') @@ -303,7 +303,7 @@ App::delete('/v1/storage/buckets/:bucketId') ->desc('Delete bucket') ->groups(['api', 'storage']) ->label('scope', 'buckets.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('audits.event', 'bucket.delete') ->label('event', 'buckets.[bucketId].delete') ->label('audits.resource', 'bucket/{request.bucketId}') @@ -346,7 +346,7 @@ App::post('/v1/storage/buckets/:bucketId/files') ->desc('Create file') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('audits.event', 'file.create') ->label('event', 'buckets.[bucketId].files.[fileId].create') ->label('audits.resource', 'file/{response.$id}') @@ -708,7 +708,7 @@ App::get('/v1/storage/buckets/:bucketId/files') ->desc('List files') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'listFiles') @@ -800,7 +800,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId') ->desc('Get file') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFile') @@ -848,7 +848,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') ->desc('Get file preview') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('cache', true) ->label('cache.resourceType', 'bucket/{request.bucketId}') ->label('cache.resource', 'file/{request.fileId}') @@ -1021,7 +1021,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') ->desc('Get file for download') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileDownload') @@ -1162,7 +1162,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') ->desc('Get file for view') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getFileView') @@ -1314,7 +1314,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') ->desc('Get file for push notification') ->groups(['api', 'storage']) ->label('scope', 'public') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', '*/*') ->label('sdk.methodType', 'location') @@ -1469,7 +1469,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') ->desc('Update file') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('event', 'buckets.[bucketId].files.[fileId].update') ->label('audits.event', 'file.update') ->label('audits.resource', 'file/{response.$id}') @@ -1574,7 +1574,7 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') ->desc('Delete file') ->groups(['api', 'storage']) ->label('scope', 'files.write') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('event', 'buckets.[bucketId].files.[fileId].delete') ->label('audits.event', 'file.delete') ->label('audits.resource', 'file/{request.fileId}') @@ -1668,7 +1668,7 @@ App::get('/v1/storage/usage') ->desc('Get storage usage stats') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getUsage') @@ -1748,7 +1748,7 @@ App::get('/v1/storage/:bucketId/usage') ->desc('Get bucket usage stats') ->groups(['api', 'storage']) ->label('scope', 'files.read') - ->label('resourceType', 'buckets') + ->label('resourceType', RESOURCE_TYPE_BUCKETS) ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'storage') ->label('sdk.method', 'getBucketUsage') diff --git a/app/controllers/general.php b/app/controllers/general.php index a5f6b38a44..59899d704b 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -137,7 +137,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo throw new AppwriteException(AppwriteException::FUNCTION_NOT_FOUND); } - if ($isResourceBlocked($project, 'functions', $functionId)) { + if ($isResourceBlocked($project, RESOURCE_TYPE_FUNCTIONS, $functionId)) { throw new AppwriteException(AppwriteException::GENERAL_RESOURCE_BLOCKED); } diff --git a/app/init.php b/app/init.php index 50ab123754..a558c0fa25 100644 --- a/app/init.php +++ b/app/init.php @@ -286,6 +286,17 @@ const METRIC_NETWORK_REQUESTS = 'network.requests'; const METRIC_NETWORK_INBOUND = 'network.inbound'; const METRIC_NETWORK_OUTBOUND = 'network.outbound'; +// Resource types + +const RESOURCE_TYPE_PROJECTS = 'projects'; +const RESOURCE_TYPE_FUNCTIONS = 'functions'; +const RESOURCE_TYPE_DATABASES = 'databases'; +const RESOURCE_TYPE_BUCKETS = 'buckets'; +const RESOURCE_TYPE_PROVIDERS = 'providers'; +const RESOURCE_TYPE_TOPICS = 'topics'; +const RESOURCE_TYPE_SUBSCRIBERS = 'subscribers'; +const RESOURCE_TYPE_MESSAGES = 'messages'; + $register = new Registry(); App::setMode(System::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 1da8c88b92..72a3334f2f 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -126,7 +126,7 @@ class Functions extends Action continue; } - if ($isResourceBlocked($project, 'functions', $function->getId())) { + if ($isResourceBlocked($project, RESOURCE_TYPE_FUNCTIONS, $function->getId())) { Console::log('Function ' . $function->getId() . ' is blocked, skipping execution.'); continue; } @@ -161,7 +161,7 @@ class Functions extends Action return; } - if ($isResourceBlocked($project, 'functions', $function->getId())) { + if ($isResourceBlocked($project, RESOURCE_TYPE_FUNCTIONS, $function->getId())) { Console::log('Function ' . $function->getId() . ' is blocked, skipping execution.'); return; }