diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index f33dffd348..528645eaca 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -7613,179 +7613,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": [ @@ -8017,30 +7844,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", @@ -9237,56 +9040,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 bf2314458f..66d90ce15f 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -30615,8 +30615,7 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30627,8 +30626,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30697,8 +30695,7 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30709,8 +30706,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30788,7 +30784,8 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30797,7 +30794,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -30846,7 +30844,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30855,7 +30854,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -30914,7 +30914,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -30923,7 +30924,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 c9f99b0188..44b9c4be42 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -21696,22 +21696,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": [ @@ -21780,22 +21777,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": [ @@ -21839,6 +21833,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 f60a2549b1..ffd7eaabe6 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -7733,174 +7733,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": [ @@ -8104,31 +7936,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", @@ -9336,56 +9143,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 6db1ccbd15..7bbc9391d3 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -30838,8 +30838,7 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30850,8 +30849,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -30920,8 +30918,7 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "client", - "server", + "console", "server" ], "packaging": false, @@ -30932,8 +30929,7 @@ "security": [ { "Project": [], - "Key": [], - "JWT": [] + "Key": [] } ], "parameters": [ @@ -31006,7 +31002,8 @@ "rate-key": "url:{url},ip:{ip}", "scope": "tokens.read", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31015,7 +31012,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -31064,7 +31062,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31073,7 +31072,8 @@ }, "security": [ { - "Project": [] + "Project": [], + "Key": [] } ], "parameters": [ @@ -31133,7 +31133,8 @@ "rate-key": "ip:{ip},method:{method},url:{url},userId:{userId}", "scope": "tokens.write", "platforms": [ - "console" + "console", + "server" ], "packaging": false, "auth": { @@ -31142,7 +31143,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 5a979359e5..554a8579a6 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -21977,22 +21977,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": [ @@ -22061,22 +22058,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": [ @@ -22115,6 +22109,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", 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: <<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; + } } 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;