From de57c8f35ed214c335e5c8384aedbb39392f7398 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 May 2025 19:04:11 +0530 Subject: [PATCH 1/5] update: token scopes. --- src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Delete.php | 2 +- src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Get.php | 2 +- src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Update.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Delete.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Delete.php index 7a9fc8d712..fcac9a6b24 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Delete.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Delete.php @@ -45,7 +45,7 @@ class Delete extends Action description: << Date: Thu, 15 May 2025 19:13:51 +0530 Subject: [PATCH 2/5] update: token scopes tests. --- .../Tokens/TokensCustomServerTest.php | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/e2e/Services/Tokens/TokensCustomServerTest.php b/tests/e2e/Services/Tokens/TokensCustomServerTest.php index f95b22cea2..fe8fa2bad9 100644 --- a/tests/e2e/Services/Tokens/TokensCustomServerTest.php +++ b/tests/e2e/Services/Tokens/TokensCustomServerTest.php @@ -85,10 +85,11 @@ class TokensCustomServerTest extends Scope // Finite expiry $expiry = DateTime::addSeconds(new \DateTime(), 3600); - $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, array_merge([ + $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ 'expire' => $expiry, ]); @@ -108,6 +109,26 @@ class TokensCustomServerTest extends Scope return $data; } + /** + * @depends testCreateToken + */ + public function testListTokens(array $data): array + { + $res = $this->client->call( + Client::METHOD_GET, + '/tokens/buckets/' . $data['bucketId'] . '/files/' . $data['fileId'], + [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ] + ); + + $this->assertIsArray($res['body']); + $this->assertEquals(200, $res['headers']['status-code']); + return $data; + } + /** * @depends testUpdateToken */ @@ -115,10 +136,11 @@ class TokensCustomServerTest extends Scope { $tokenId = $data['tokenId']; - $res = $this->client->call(Client::METHOD_DELETE, '/tokens/' . $tokenId, array_merge([ + $res = $this->client->call(Client::METHOD_DELETE, '/tokens/' . $tokenId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); $this->assertEquals(204, $res['headers']['status-code']); return $data; From bebd1036118b8ac1c21b27cc23db2ec7283b9705 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 May 2025 19:22:53 +0530 Subject: [PATCH 3/5] update: token scopes tests for console client. --- .../Tokens/TokensConsoleClientTest.php | 134 +++++++++++++++++- 1 file changed, 132 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Tokens/TokensConsoleClientTest.php b/tests/e2e/Services/Tokens/TokensConsoleClientTest.php index 1ce72335dd..4a7aab474a 100644 --- a/tests/e2e/Services/Tokens/TokensConsoleClientTest.php +++ b/tests/e2e/Services/Tokens/TokensConsoleClientTest.php @@ -2,13 +2,143 @@ namespace Tests\E2E\Services\Tokens; +use CURLFile; +use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; -use Tests\E2E\Scopes\SideConsole; +use Tests\E2E\Scopes\SideServer; +use Utopia\Database\DateTime; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; +use Utopia\Database\Validator\Datetime as DatetimeValidator; class TokensConsoleClientTest extends Scope { - use SideConsole; use TokensBase; use ProjectCustom; + use SideServer; + + public function testCreateToken(): array + { + + $bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'bucketId' => ID::unique(), + 'name' => 'Test Bucket', + 'fileSecurity' => true, + 'maximumFileSize' => 2000000, //2MB + 'allowedFileExtensions' => ['jpg', 'png', 'jfif'], + 'permissions' => [ + Permission::read(Role::any()), + Permission::create(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + $this->assertEquals(201, $bucket['headers']['status-code']); + $this->assertNotEmpty($bucket['body']['$id']); + + $bucketId = $bucket['body']['$id']; + + $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'fileId' => ID::unique(), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + 'permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + $this->assertEquals(201, $file['headers']['status-code']); + $this->assertNotEmpty($file['body']['$id']); + + $fileId = $file['body']['$id']; + + $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders())); + + $this->assertEquals(201, $token['headers']['status-code']); + $this->assertEquals('files', $token['body']['resourceType']); + + return [ + 'fileId' => $fileId, + 'bucketId' => $bucketId, + 'tokenId' => $token['body']['$id'], + ]; + } + + /** + * @depends testCreateToken + */ + public function testUpdateToken(array $data): array + { + $tokenId = $data['tokenId']; + + // Finite expiry + $expiry = DateTime::addSeconds(new \DateTime(), 3600); + $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'expire' => $expiry, + ]); + + $dateValidator = new DatetimeValidator(); + $this->assertTrue($dateValidator->isValid($token['body']['expire'])); + + // Infinite expiry + $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'expire' => null, + ]); + + $this->assertEmpty($token['body']['expire']); + + return $data; + } + + /** + * @depends testCreateToken + */ + public function testListTokens(array $data): array + { + $res = $this->client->call( + Client::METHOD_GET, + '/tokens/buckets/' . $data['bucketId'] . '/files/' . $data['fileId'], + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()) + ); + + $this->assertIsArray($res['body']); + $this->assertEquals(200, $res['headers']['status-code']); + return $data; + } + + /** + * @depends testUpdateToken + */ + public function testDeleteToken(array $data): array + { + $tokenId = $data['tokenId']; + + $res = $this->client->call(Client::METHOD_DELETE, '/tokens/' . $tokenId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders())); + + $this->assertEquals(204, $res['headers']['status-code']); + return $data; + } } From f0a835b3b23009b3abf599b7dcc08f15bc2cc35e Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 May 2025 19:37:07 +0530 Subject: [PATCH 4/5] update: token scopes tests for console client. --- .../Modules/Tokens/Http/Tokens/Buckets/Files/Create.php | 2 +- .../Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php index 0ac9424937..4b3b421696 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php @@ -50,7 +50,7 @@ class Create extends Action description: << Date: Fri, 16 May 2025 11:05:05 +0530 Subject: [PATCH 5/5] update: specs for sdk gen. --- app/config/specs/open-api3-latest-client.json | 247 ------------------ .../specs/open-api3-latest-console.json | 30 ++- app/config/specs/open-api3-latest-server.json | 213 ++++++++++++++- app/config/specs/swagger2-latest-client.json | 243 ----------------- app/config/specs/swagger2-latest-console.json | 30 ++- app/config/specs/swagger2-latest-server.json | 212 ++++++++++++++- 6 files changed, 433 insertions(+), 542 deletions(-) diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 80aa4cf420..355ea4800f 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -7633,179 +7633,6 @@ } } } - }, - "\/tokens\/buckets\/{bucketId}\/files\/{fileId}": { - "get": { - "summary": "List tokens", - "operationId": "tokensList", - "tags": [ - "tokens" - ], - "description": "List all the tokens created for a specific file or bucket. You can use the query params to filter your results.", - "responses": { - "200": { - "description": "Resource Tokens List", - "content": { - "application\/json": { - "schema": { - "$ref": "#\/components\/schemas\/resourceTokenList" - } - } - } - } - }, - "x-appwrite": { - "method": "list", - "group": "files", - "weight": 438, - "cookies": false, - "type": "", - "deprecated": false, - "demo": "tokens\/list.md", - "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterList all the tokens created for a specific file or bucket. You can use the query params to filter your results.", - "rate-limit": 0, - "rate-time": 3600, - "rate-key": "url:{url},ip:{ip}", - "scope": "tokens.read", - "platforms": [ - "client", - "server", - "server" - ], - "packaging": false, - "auth": { - "Project": [] - } - }, - "security": [ - { - "Project": [], - "Session": [], - "JWT": [] - } - ], - "parameters": [ - { - "name": "bucketId", - "description": "Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https:\/\/appwrite.io\/docs\/server\/storage#createBucket).", - "required": true, - "schema": { - "type": "string", - "x-example": "" - }, - "in": "path" - }, - { - "name": "fileId", - "description": "File unique ID.", - "required": true, - "schema": { - "type": "string", - "x-example": "" - }, - "in": "path" - }, - { - "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire", - "required": false, - "schema": { - "type": "string", - "default": [] - }, - "in": "query" - } - ] - }, - "post": { - "summary": "Create file token", - "operationId": "tokensCreateFileToken", - "tags": [ - "tokens" - ], - "description": "Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter.", - "responses": { - "201": { - "description": "ResourceToken", - "content": { - "application\/json": { - "schema": { - "$ref": "#\/components\/schemas\/resourceToken" - } - } - } - } - }, - "x-appwrite": { - "method": "createFileToken", - "group": "files", - "weight": 436, - "cookies": false, - "type": "", - "deprecated": false, - "demo": "tokens\/create-file-token.md", - "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterCreate a new token. A token is linked to a file. Token can be passed as a header or request get parameter.", - "rate-limit": 60, - "rate-time": 60, - "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", - "scope": "tokens.write", - "platforms": [ - "client", - "server", - "server" - ], - "packaging": false, - "auth": { - "Project": [] - } - }, - "security": [ - { - "Project": [], - "Session": [], - "JWT": [] - } - ], - "parameters": [ - { - "name": "bucketId", - "description": "Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https:\/\/appwrite.io\/docs\/server\/storage#createBucket).", - "required": true, - "schema": { - "type": "string", - "x-example": "" - }, - "in": "path" - }, - { - "name": "fileId", - "description": "File unique ID.", - "required": true, - "schema": { - "type": "string", - "x-example": "" - }, - "in": "path" - } - ], - "requestBody": { - "content": { - "application\/json": { - "schema": { - "type": "object", - "properties": { - "expire": { - "type": "string", - "description": "Token expiry date", - "x-example": null, - "x-nullable": true - } - } - } - } - } - } - } } }, "tags": [ @@ -8037,30 +7864,6 @@ "files" ] }, - "resourceTokenList": { - "description": "Resource Tokens List", - "type": "object", - "properties": { - "total": { - "type": "integer", - "description": "Total number of tokens documents that matched your query.", - "x-example": 5, - "format": "int32" - }, - "tokens": { - "type": "array", - "description": "List of tokens.", - "items": { - "$ref": "#\/components\/schemas\/resourceToken" - }, - "x-example": "" - } - }, - "required": [ - "total", - "tokens" - ] - }, "teamList": { "description": "Teams List", "type": "object", @@ -9257,56 +9060,6 @@ "chunksUploaded" ] }, - "resourceToken": { - "description": "ResourceToken", - "type": "object", - "properties": { - "$id": { - "type": "string", - "description": "Token ID.", - "x-example": "bb8ea5c16897e" - }, - "$createdAt": { - "type": "string", - "description": "Token creation date in ISO 8601 format.", - "x-example": "2020-10-15T06:38:00.000+00:00" - }, - "resourceId": { - "type": "string", - "description": "Resource ID.", - "x-example": "5e5ea5c168bb8:5e5ea5c168bb8" - }, - "resourceType": { - "type": "string", - "description": "Resource type.", - "x-example": "files" - }, - "expire": { - "type": "string", - "description": "Token expiration date in ISO 8601 format.", - "x-example": "2020-10-15T06:38:00.000+00:00" - }, - "secret": { - "type": "string", - "description": "JWT encoded string.", - "x-example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" - }, - "accessedAt": { - "type": "string", - "description": "Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.", - "x-example": "2020-10-15T06:38:00.000+00:00" - } - }, - "required": [ - "$id", - "$createdAt", - "resourceId", - "resourceType", - "expire", - "secret", - "accessedAt" - ] - }, "team": { "description": "Team", "type": "object", diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index d9e216ed14..f1df40d7d9 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -30625,8 +30625,7 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30637,8 +30636,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30707,8 +30705,7 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30719,8 +30716,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30798,7 +30794,8 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30807,7 +30804,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -30856,7 +30854,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30865,7 +30864,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -30924,7 +30924,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30933,7 +30934,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 509337fc81..8c94f21bad 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -21706,22 +21706,19 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, "auth": { "Project": [], - "Session": [] + "Key": [] } }, "security": [ { "Project": [], - "Session": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -21790,22 +21787,19 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, "auth": { "Project": [], - "Session": [] + "Key": [] } }, "security": [ { "Project": [], - "Session": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -21849,6 +21843,201 @@ } } }, + "\/tokens\/{tokenId}": { + "get": { + "summary": "Get token", + "operationId": "tokensGet", + "tags": [ + "tokens" + ], + "description": "Get a token by its unique ID.", + "responses": { + "200": { + "description": "ResourceToken", + "content": { + "application\/json": { + "schema": { + "$ref": "#\/components\/schemas\/resourceToken" + } + } + } + } + }, + "x-appwrite": { + "method": "get", + "group": "tokens", + "weight": 437, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/get.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterGet a token by its unique ID.", + "rate-limit": 0, + "rate-time": 3600, + "rate-key": "url:{url},ip:{ip}", + "scope": "tokens.read", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token ID.", + "required": true, + "schema": { + "type": "string", + "x-example": "" + }, + "in": "path" + } + ] + }, + "patch": { + "summary": "Update token", + "operationId": "tokensUpdate", + "tags": [ + "tokens" + ], + "description": "Update a token by its unique ID. Use this endpoint to update a token's expiry date.", + "responses": { + "200": { + "description": "ResourceToken", + "content": { + "application\/json": { + "schema": { + "$ref": "#\/components\/schemas\/resourceToken" + } + } + } + } + }, + "x-appwrite": { + "method": "update", + "group": "tokens", + "weight": 439, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/update.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterUpdate a token by its unique ID. Use this endpoint to update a token's expiry date.", + "rate-limit": 60, + "rate-time": 60, + "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", + "scope": "tokens.write", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token unique ID.", + "required": true, + "schema": { + "type": "string", + "x-example": "" + }, + "in": "path" + } + ], + "requestBody": { + "content": { + "application\/json": { + "schema": { + "type": "object", + "properties": { + "expire": { + "type": "string", + "description": "File token expiry date", + "x-example": null, + "x-nullable": true + } + } + } + } + } + } + }, + "delete": { + "summary": "Delete token", + "operationId": "tokensDelete", + "tags": [ + "tokens" + ], + "description": "Delete a token by its unique ID.", + "responses": { + "204": { + "description": "No content" + } + }, + "x-appwrite": { + "method": "delete", + "group": "tokens", + "weight": 440, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/delete.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterDelete a token by its unique ID.", + "rate-limit": 60, + "rate-time": 60, + "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", + "scope": "tokens.write", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token ID.", + "required": true, + "schema": { + "type": "string", + "x-example": "" + }, + "in": "path" + } + ] + } + }, "\/users": { "get": { "summary": "List users", diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 5bb98a8c0f..49b1cb9989 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -7753,174 +7753,6 @@ } ] } - }, - "\/tokens\/buckets\/{bucketId}\/files\/{fileId}": { - "get": { - "summary": "List tokens", - "operationId": "tokensList", - "consumes": [], - "produces": [ - "application\/json" - ], - "tags": [ - "tokens" - ], - "description": "List all the tokens created for a specific file or bucket. You can use the query params to filter your results.", - "responses": { - "200": { - "description": "Resource Tokens List", - "schema": { - "$ref": "#\/definitions\/resourceTokenList" - } - } - }, - "x-appwrite": { - "method": "list", - "group": "files", - "weight": 438, - "cookies": false, - "type": "", - "deprecated": false, - "demo": "tokens\/list.md", - "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterList all the tokens created for a specific file or bucket. You can use the query params to filter your results.", - "rate-limit": 0, - "rate-time": 3600, - "rate-key": "url:{url},ip:{ip}", - "scope": "tokens.read", - "platforms": [ - "client", - "server", - "server" - ], - "packaging": false, - "auth": { - "Project": [] - } - }, - "security": [ - { - "Project": [], - "Session": [], - "JWT": [] - } - ], - "parameters": [ - { - "name": "bucketId", - "description": "Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https:\/\/appwrite.io\/docs\/server\/storage#createBucket).", - "required": true, - "type": "string", - "x-example": "", - "in": "path" - }, - { - "name": "fileId", - "description": "File unique ID.", - "required": true, - "type": "string", - "x-example": "", - "in": "path" - }, - { - "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire", - "required": false, - "type": "array", - "collectionFormat": "multi", - "items": { - "type": "string" - }, - "default": [], - "in": "query" - } - ] - }, - "post": { - "summary": "Create file token", - "operationId": "tokensCreateFileToken", - "consumes": [ - "application\/json" - ], - "produces": [ - "application\/json" - ], - "tags": [ - "tokens" - ], - "description": "Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter.", - "responses": { - "201": { - "description": "ResourceToken", - "schema": { - "$ref": "#\/definitions\/resourceToken" - } - } - }, - "x-appwrite": { - "method": "createFileToken", - "group": "files", - "weight": 436, - "cookies": false, - "type": "", - "deprecated": false, - "demo": "tokens\/create-file-token.md", - "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterCreate a new token. A token is linked to a file. Token can be passed as a header or request get parameter.", - "rate-limit": 60, - "rate-time": 60, - "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", - "scope": "tokens.write", - "platforms": [ - "client", - "server", - "server" - ], - "packaging": false, - "auth": { - "Project": [] - } - }, - "security": [ - { - "Project": [], - "Session": [], - "JWT": [] - } - ], - "parameters": [ - { - "name": "bucketId", - "description": "Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https:\/\/appwrite.io\/docs\/server\/storage#createBucket).", - "required": true, - "type": "string", - "x-example": "", - "in": "path" - }, - { - "name": "fileId", - "description": "File unique ID.", - "required": true, - "type": "string", - "x-example": "", - "in": "path" - }, - { - "name": "payload", - "in": "body", - "schema": { - "type": "object", - "properties": { - "expire": { - "type": "string", - "description": "Token expiry date", - "default": null, - "x-example": null, - "x-nullable": true - } - } - } - } - ] - } } }, "tags": [ @@ -8124,31 +7956,6 @@ "files" ] }, - "resourceTokenList": { - "description": "Resource Tokens List", - "type": "object", - "properties": { - "total": { - "type": "integer", - "description": "Total number of tokens documents that matched your query.", - "x-example": 5, - "format": "int32" - }, - "tokens": { - "type": "array", - "description": "List of tokens.", - "items": { - "type": "object", - "$ref": "#\/definitions\/resourceToken" - }, - "x-example": "" - } - }, - "required": [ - "total", - "tokens" - ] - }, "teamList": { "description": "Teams List", "type": "object", @@ -9356,56 +9163,6 @@ "chunksUploaded" ] }, - "resourceToken": { - "description": "ResourceToken", - "type": "object", - "properties": { - "$id": { - "type": "string", - "description": "Token ID.", - "x-example": "bb8ea5c16897e" - }, - "$createdAt": { - "type": "string", - "description": "Token creation date in ISO 8601 format.", - "x-example": "2020-10-15T06:38:00.000+00:00" - }, - "resourceId": { - "type": "string", - "description": "Resource ID.", - "x-example": "5e5ea5c168bb8:5e5ea5c168bb8" - }, - "resourceType": { - "type": "string", - "description": "Resource type.", - "x-example": "files" - }, - "expire": { - "type": "string", - "description": "Token expiration date in ISO 8601 format.", - "x-example": "2020-10-15T06:38:00.000+00:00" - }, - "secret": { - "type": "string", - "description": "JWT encoded string.", - "x-example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" - }, - "accessedAt": { - "type": "string", - "description": "Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.", - "x-example": "2020-10-15T06:38:00.000+00:00" - } - }, - "required": [ - "$id", - "$createdAt", - "resourceId", - "resourceType", - "expire", - "secret", - "accessedAt" - ] - }, "team": { "description": "Team", "type": "object", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index bf430b6e63..873d4fda31 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -30847,8 +30847,7 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30859,8 +30858,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30929,8 +30927,7 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30941,8 +30938,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -31015,7 +31011,8 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31024,7 +31021,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -31073,7 +31071,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31082,7 +31081,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -31142,7 +31142,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31151,7 +31152,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 302a486e1f..e63988d896 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -21986,22 +21986,19 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, "auth": { "Project": [], - "Session": [] + "Key": [] } }, "security": [ { "Project": [], - "Session": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -22070,22 +22067,19 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, "auth": { "Project": [], - "Session": [] + "Key": [] } }, "security": [ { "Project": [], - "Session": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -22124,6 +22118,200 @@ ] } }, + "\/tokens\/{tokenId}": { + "get": { + "summary": "Get token", + "operationId": "tokensGet", + "consumes": [], + "produces": [ + "application\/json" + ], + "tags": [ + "tokens" + ], + "description": "Get a token by its unique ID.", + "responses": { + "200": { + "description": "ResourceToken", + "schema": { + "$ref": "#\/definitions\/resourceToken" + } + } + }, + "x-appwrite": { + "method": "get", + "group": "tokens", + "weight": 437, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/get.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterGet a token by its unique ID.", + "rate-limit": 0, + "rate-time": 3600, + "rate-key": "url:{url},ip:{ip}", + "scope": "tokens.read", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token ID.", + "required": true, + "type": "string", + "x-example": "", + "in": "path" + } + ] + }, + "patch": { + "summary": "Update token", + "operationId": "tokensUpdate", + "consumes": [ + "application\/json" + ], + "produces": [ + "application\/json" + ], + "tags": [ + "tokens" + ], + "description": "Update a token by its unique ID. Use this endpoint to update a token's expiry date.", + "responses": { + "200": { + "description": "ResourceToken", + "schema": { + "$ref": "#\/definitions\/resourceToken" + } + } + }, + "x-appwrite": { + "method": "update", + "group": "tokens", + "weight": 439, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/update.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterUpdate a token by its unique ID. Use this endpoint to update a token's expiry date.", + "rate-limit": 60, + "rate-time": 60, + "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", + "scope": "tokens.write", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token unique ID.", + "required": true, + "type": "string", + "x-example": "", + "in": "path" + }, + { + "name": "payload", + "in": "body", + "schema": { + "type": "object", + "properties": { + "expire": { + "type": "string", + "description": "File token expiry date", + "default": null, + "x-example": null, + "x-nullable": true + } + } + } + } + ] + }, + "delete": { + "summary": "Delete token", + "operationId": "tokensDelete", + "consumes": [ + "application\/json" + ], + "produces": [], + "tags": [ + "tokens" + ], + "description": "Delete a token by its unique ID.", + "responses": { + "204": { + "description": "No content" + } + }, + "x-appwrite": { + "method": "delete", + "group": "tokens", + "weight": 440, + "cookies": false, + "type": "", + "deprecated": false, + "demo": "tokens\/delete.md", + "edit": "https:\/\/github.com\/appwrite\/appwrite\/edit\/masterDelete a token by its unique ID.", + "rate-limit": 60, + "rate-time": 60, + "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", + "scope": "tokens.write", + "platforms": [ + "console", + "server" + ], + "packaging": false, + "auth": { + "Project": [], + "Key": [] + } + }, + "security": [ + { + "Project": [], + "Key": [] + } + ], + "parameters": [ + { + "name": "tokenId", + "description": "Token ID.", + "required": true, + "type": "string", + "x-example": "", + "in": "path" + } + ] + } + }, "\/users": { "get": { "summary": "List users",