From 419d1aff5d755cc51e17af951fd8e7018381e6df Mon Sep 17 00:00:00 2001 From: AstaFrode Date: Wed, 31 Jan 2024 20:38:40 +0800 Subject: [PATCH] Update README.md (#131) --- README.md | 111 ++++++++++-------------------------------------------- 1 file changed, 19 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index 5d4b83b..e084f4e 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ service iptables restart ### Method one Download the latest release of the binary application directly at: ``` -wget https://github.com/CESSProject/DeOSS/releases/download/v0.3.4/DeOSS0.3.4.linux-amd64.tar.gz +wget https://github.com/CESSProject/DeOSS/releases/download/v0.3.5/DeOSS0.3.5.linux-amd64.tar.gz ``` ### Method two @@ -216,64 +216,18 @@ The public API endpoint URL of DeOSS is the server you deploy, All endpoints des > If you feel that you do not have enough space, you can expand it by means of [ExpansionSpace](https://github.com/CESSProject/W3F-illustration/blob/4995c1584006823990806b9d30fa7d554630ec14/deoss/expansionSpace.png). -## Authentication - -The DeOSS API uses bearer tokens to authenticate requests. - -Your tokens carry many privileges, so be sure to keep them secure! Do not share your *secret tokens* in publicly accessible locations such as a GitHub repository, client-side code, and so forth. - -The bearer token is a cryptic string, usually generated by the server in response to a auth request. The client must send this token in the `Authorization` header when making requests to protected resources: - -| Authorization: token | -| --------------------- | - - -## Get token - -| **POST** /auth | -| --------------- | - -The authorization interface is used to generate user tokens. - -- Request Header - -| key | value | -| ------------ | ---------------- | -| Content-Type | application/json | - -- Request Body - -| field | value | -| ------- | ----------------------------- | -| account | your account address | -| message | custom Signature Message | -| signature | signature data | - -*Reference for signature calculation method: https://github.com/CESSProject/cess-toolset/tree/main/cess-sign* - - -- Responses - -Response schema: `application/json` - -| HTTP Code | Message | Description | -| --------- | -------------------------- | ----------------------------- | -| 200 | token | returns a token | -| 400 | Invalid.Body | body content error | -| 400 | InvalidParameter.Account | account error | -| 400 | InvalidParameter.Message | message error | -| 400 | InvalidParameter.Signature | signature error | -| 403 | NoPermission | signature verification failed | -| 500 | InternalError | service internal error | - -- Request example - -```shell -# curl -X POST URL/auth -d '{"account": "cXgfFb...bjfR", "message": "123456", "signature": [44,30,117,...,109,141]}' -H "Content-Type: application/json" -``` +## Public request header +The public request header identifies you, all interfaces require you to provide identity information, the easiest way to do this is to sign with your account in the [block browser](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftestnet-rpc1.cess.cloud%2Fws%2F#/signing) and then fill in the information into the public request header as follows: +| key | value | +| --------- | ----- | +| Account | cX... | +| Message | ... | +| Signature | 0x... | +:warning:Please add public request header information to all requests. + ## Create a bucket | **PUT** / | @@ -304,7 +258,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X PUT URL/ -H "BucketName: bucketname" -H "Authorization: eyJhbGciOiJIUzI1NiIsI......P0Jrg-hX4bXlIyn5I8ML1g" +# curl -X PUT URL/ -H "BucketName: bucketname" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## Upload a file @@ -319,7 +273,6 @@ If the upload is successful, you will get the fid of the file. If you want to en | key | description | | ------------- | ------------------ | -| Authorization | token | | BucketName | stored bucket name | | cipher | your cipher | @@ -355,7 +308,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X PUT URL/ -F 'file=@test.log;type=application/octet-stream' -H "Authorization: eyJhbGciOiJIUzI...Iyn5I8ML1g" -H "BucketName: bucket1" +# curl -X PUT URL/ -F 'file=@test.log;type=application/octet-stream' -H "BucketName: bucket1" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## Download a file @@ -370,7 +323,6 @@ The get file interface downloads the file in the CESS storage system according t | key | value | | --------- | -------- | | Operation | download | -| Account | cX... | - Responses @@ -388,7 +340,7 @@ The response schema for the exception return status is: `application/json`, The - Request example ```shell -# curl -X GET -o URL/fid -H "Operation: download" +# curl -X GET -o URL/fid -H "Operation: download" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## Delete a file @@ -398,12 +350,6 @@ The delete file interface is used for delete a put file. | **DELETE** /{fid} | | ------------------ | -- Request Header - -| key | value | -| ------------- | ----- | -| Authorization | token | - - Responses Response schema: `application/json` @@ -420,7 +366,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X DELETE URL/fid -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g" +# curl -X DELETE URL/fid -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## Delete multiple files @@ -464,7 +410,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X DELETE URL/ -d '{"files": ["filehash1", "filehash2"]}' -H "Content-Type: application/json" -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g" +# curl -X DELETE URL/ -d '{"files": ["filehash1", "filehash2"]}' -H "Content-Type: application/json" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## Delete a bucket @@ -474,12 +420,6 @@ The delete bucket interface is used for delete a bucket, all files in the bucket | **DELETE** /{BucketName} | | ------------------------- | -- Request Header - -| key | value | -| ------------- | ----- | -| Authorization | token | - - Responses Response schema: `application/json` @@ -496,7 +436,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X DELETE URL/BucketName -H "Authorization: eyJhbGciOiJIUzI1Ni......g-hX4bXlIyn5I8ML1g" +# curl -X DELETE URL/BucketName -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## View bucket info @@ -506,12 +446,6 @@ Response schema: `application/json` This interface is used to view bucket information, including the number of stored files and file IDs. -- Request Header - -| key | description | -| ------- | --------------- | -| Account | account address | - - Responses Response schema: `application/json` @@ -528,7 +462,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X GET URL/BucketName -H "Account: cXgfFbnV9H......PMQLoKbjfR" +# curl -X GET URL/BucketName -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## View bucket list @@ -538,12 +472,6 @@ Response schema: `application/json` This interface is used to view all buckets. -- Request Header - -| key | description | -| ------- | --------------- | -| Account | account address | - - Responses Response schema: `application/json` @@ -560,7 +488,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X GET URL/* -H "Account: cXgfFbnV9H......PMQLoKbjfR" +# curl -X GET URL/* -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## View file info @@ -575,7 +503,6 @@ This interface is used to view the basic information of a file. | key | value | | --------- | ----- | | Operation | view | -| Account | cX... | - Responses @@ -591,7 +518,7 @@ Response schema: `application/json` - Request example ```shell -# curl -X GET URL/fid -H "Operation: view" +# curl -X GET URL/fid -H "Operation: view" -H "Account: cX..." -H "Message: ..." -H "Signature: 0x..." ``` ## License