Skip to content

Commit

Permalink
#33 Update (partial) the docs with auth token header
Browse files Browse the repository at this point in the history
  • Loading branch information
SrMouraSilva committed Mar 15, 2018
1 parent bda12cf commit b85b476
Show file tree
Hide file tree
Showing 18 changed files with 245 additions and 117 deletions.
9 changes: 8 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 0.4.0 - released mm/dd/18
Version 0.4.0 - released 05/dd/18
=================================

- Issue #45 - Add Makefile
Expand All @@ -7,6 +7,13 @@ Version 0.4.0 - released mm/dd/18
- PluginsManager v0.4.0? -> v0.7.0
- Application v0.2.0 -> v0.4.0

- Issue #33 - Add auth

- Breaking change!
- See http://pedalpi.github.io/WebService/ for details

- Improve errors when is not passed all parameters

Version 0.3.0 - released 05/31/17
=================================

Expand Down
103 changes: 48 additions & 55 deletions docs/index.html

Large diffs are not rendered by default.

61 changes: 39 additions & 22 deletions docs/section/authentication.apib
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The token has a expiration of **7 days** from login response time. If the token
expired, is necessary request auth to obtains a new token.
:::

+ Request 200 (application/json; charset=UTF-8)
+ Request (application/json; charset=UTF-8)

+ Body

Expand All @@ -53,37 +53,54 @@ This is an example how to request something.
### Example request [GET]

::: note
The Authorization error are the code `401`. The possible errors are
The Authorization code error is `401`.

* Is not send the header Authorization
```
{"error": "Missing authorization"}
```
* The Authorization header not match with the standart `Authorization: bearer <token>`
```
{"error": "Invalid header authorization"}
```
* Is sent a auth token with other signature
```
{"error": "Signature verification failed"}
```
* The token auth has expired.
```
{"error": "Signature has expired"}
```
See the possible errors in right selecting a request.
:::

+ Request 200 (application/json; charset=UTF-8)

+ Request successful (application/json; charset=UTF-8)
+ Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MjE5ODM1NDZ9.MKT1XRgqa68ADIdH1ro0MkIWwh9mXrNPjz5q5aUhFKc

+ Response 200 (application/json; charset=UTF-8)
+ Body

something


+ Request without Authorization (application/json; charset=UTF-8)
+ Response 401 (application/json; charset=UTF-8)
+ Body

{"error": "Missing authorization"}

+ Request invalid Authorization standart (application/json; charset=UTF-8)
+ Headers

Authorization: bearer something eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MjE5ODM1NDZ9.MKT1XRgqa68ADIdH1ro0MkIWwh9mXrNPjz5q5aUhFKc
+ Response 401 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid header authorization. The Authorization header not match with the standart `Authorization: bearer <token>`"}

+ Request token with wrong signature (application/json; charset=UTF-8)
+ Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MjE5ODM1NDZ9.MKT1XRgqa68ADIdH1ro0MkIWwh9mXrNPjz5q5aUhFKc
+ Response 401 (application/json; charset=UTF-8)
+ Body

{"error": "Signature verification failed"}

+ Request token expired (application/json; charset=UTF-8)
+ Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MjE5ODM1NDZ9.MKT1XRgqa68ADIdH1ro0MkIWwh9mXrNPjz5q5aUhFKc
+ Response 401 (application/json; charset=UTF-8)
+ Body

{"error": "Signature has expired"}

## Token identifier [/ws]

With a token identifier, it is possible to send changes if they are identified, so that no notifications of their own changes to WebSocket occur.
Expand All @@ -110,7 +127,7 @@ AWhen obtained the access token, all the requests needs

It's a example request for a random address

+ Request 200 (application/json; charset=UTF-8)
+ Request (application/json; charset=UTF-8)

+ Headers

Expand Down
30 changes: 27 additions & 3 deletions docs/section/bank.apib
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ It's necessary updates the (client) bank data with the returned index.
:::

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Body

<!-- include(bank_post.json) -->
Expand All @@ -30,22 +35,34 @@ Request a bank data with the bank index.

+ Parameters
+ bank_index: `1` (number, required) - Bank index
+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)
+ Body

<!-- include(bank_get.json) -->
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Update by index [PUT]

Update a bank

+ Parameters
+ bank_index: `1` (number, required) - Bank index

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Body

<!-- include(bank_post.json) -->
Expand All @@ -54,16 +71,23 @@ Update a bank
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Delete by index [DELETE]

Delete a bank

+ Parameters
+ bank_index: `1` (number, required) - Bank index

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}
7 changes: 7 additions & 0 deletions docs/section/banks.apib
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ Manages the banks data.
### List banks [GET]
Get all banks

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)

+ Body

{
Expand Down
21 changes: 18 additions & 3 deletions docs/section/effect.apib
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ The effect position in pedalboard effects list is returned.
The effect does not have an identifier, the returned index is only for listing and sorting purpose.
:::

+ Request 201 (application/json; charset=UTF-8)
+ Request (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>
+ Body

<!-- include(effect.json) -->
Expand All @@ -41,21 +44,33 @@ The effect does not have an identifier, the returned index is only for listing a

Request a effect data with the your index (effect position in pedalboard effects list).

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)
+ Body

<!-- include(effect.json) -->
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Delete by index position [DELETE]

Delete a effect

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}
6 changes: 3 additions & 3 deletions docs/section/param.apib
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Request a param data with the your position
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Update by index position [PUT]

Update a pedalboard

+ Request 200 (text/plain)
+ Request (text/plain)
+ Body

1.1901190476159431
Expand All @@ -39,4 +39,4 @@ Update a pedalboard
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}
31 changes: 26 additions & 5 deletions docs/section/pedalboard.apib
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ The pedalboard position in bank pedalboards list is returned
The pedalboard does not have an identifier, the returned index is only for listing and sorting purpose.
:::

+ Request 201 (application/json; charset=UTF-8)

+ Request (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>

+ Body

<!-- include(pedalboard_post.json) -->
Expand All @@ -35,20 +40,30 @@ The pedalboard does not have an identifier, the returned index is only for listi

Request a pedalboard data with the your index (pedalboard position in bank pedalboards list).

+ Request (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>


+ Response 200 (application/json; charset=UTF-8)
+ Body

<!-- include(pedalboard_post.json) -->
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Update by index position [PUT]

Update a pedalboard

+ Request 200 (application/json; charset=UTF-8)
+ Request (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>

+ Body

<!-- include(pedalboard_post.json) -->
Expand All @@ -57,14 +72,20 @@ Update a pedalboard
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}

### Delete by index position [DELETE]

Delete a pedalboard

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200
+ Response 400 (application/json; charset=UTF-8)
+ Body

{"error": "Invalid index"}
{"error": "list index out of range"}
18 changes: 15 additions & 3 deletions docs/section/pedalboard_data.apib
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ If the request with a `key` that not data has been not persisted yet, the respon
```
:::

+ Request 200 (application/json; charset=UTF-8)
+ Request with content (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)
+ Body

{"effectPositions": [{"x": 159.74801635742188, "y": 91.4995002746582}]}
+ Request 200 (application/json; charset=UTF-8)
+ Request possibly without content (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)
+ Body

Expand All @@ -70,7 +78,11 @@ Update the data for a pedalboard
If any data has been not persisted yet, uses **PUT** too instread **POST** method (POST method has been not implemented)
:::

+ Request 200 (application/json; charset=UTF-8)
+ Request (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>

+ Body

{"effectPositions": [{"x": 159.74801635742188, "y": 91.4995002746582}]}
Expand Down
6 changes: 6 additions & 0 deletions docs/section/plugins.apib
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ It's possible obtains the Lv2Plugins data in a json format. Pedal Pi uses [lilvl

Get all audio plugins installed

+ Request (application/json; charset=UTF-8)

+ Headers

Authorization: bearer <auth token>

+ Response 200 (application/json; charset=UTF-8)
+ Body

Expand Down
Loading

0 comments on commit b85b476

Please sign in to comment.