Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1ee19ea
#45 Create makefile
SrMouraSilva Feb 17, 2018
79bcee8
#45 Test stage multiple requirements
SrMouraSilva Feb 17, 2018
ea7ce80
#45 Test stage multiple requirements
SrMouraSilva Feb 17, 2018
4b1c127
#45 Makefile
SrMouraSilva Feb 17, 2018
1016cd1
#44 Connection new way
SrMouraSilva Feb 17, 2018
7142ab7
#44 Improve CI
SrMouraSilva Feb 17, 2018
f890932
#44 #45 Improve build and CHANGELOG
SrMouraSilva Mar 9, 2018
6bf9a13
#44 Build
SrMouraSilva Mar 9, 2018
4f814cc
#44 Improve message error when Param value are wrong defined
SrMouraSilva Mar 9, 2018
db5b7b9
issue #44 Add @exception and test for connection json without type de…
SrMouraSilva Mar 12, 2018
535923d
#44 Update connection docs
SrMouraSilva Mar 13, 2018
ea2cdf2
#33 Auth with @decorator
SrMouraSilva Mar 15, 2018
e7b7623
issue #33 Auth with tornado.prepare strategy
SrMouraSilva Mar 15, 2018
7b369cb
issue #33 Auth with tornado.prepare strategy
SrMouraSilva Mar 15, 2018
bda12cf
Issue #33 add `ws/auth` docs.
SrMouraSilva Mar 15, 2018
b85b476
#33 Update (partial) the docs with auth token header
SrMouraSilva Mar 15, 2018
c4183b5
#33 Auth on methods. Add Authorization: bearer <auth token> in doc
SrMouraSilva Mar 15, 2018
2236247
#33 Improve auth tests
SrMouraSilva Mar 15, 2018
36c1a6e
#33 Improve requirement
SrMouraSilva Mar 15, 2018
ac0d428
#33 Fix requirement
SrMouraSilva Mar 15, 2018
675adb1
issue #33 Fix Cors and Authentication. Fix websocket received data
SrMouraSilva Mar 17, 2018
06f6941
#33 Defined username and password for webservice components. Improve …
SrMouraSilva Mar 18, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ python:
sudo: required

install:
- sudo apt-get update
- sudo apt-get install -y portaudio19-dev python-all-dev --no-install-recommends
- sudo apt-get install -y lilv-utils calf-plugins guitarix --no-install-recommends
- sudo apt-get install -y libavahi-compat-libdnssd1 --no-install-recommends
- pip3 install coveralls
- pip3 install git+https://github.com/depl0y/pybonjour-python3
- pip3 install zeroconf
- python3 setup.py develop
- make install-develop-requirements
- make install-tests-requirements
- python setup.py develop

script:
- lv2ls
- coverage3 run --source=webservice wstest/config.py test
- make test

after_success:
- 'bash <(curl -s https://codecov.io/bash)'
- bash <(curl -s https://codecov.io/bash)

jobs:
include:
- stage: doc
script:
- make install-docs-requirements
- make docs
27 changes: 24 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
Version 0.4.0 - released 05/dd/18
=================================

- Issue #45 - Add Makefile
- Issue #44 - Update libraries

- 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
- Components that uses WebService can be use WSParameters.COMPONENT_USERNAME and WSParameters.COMPONENT_PASSWORD for auth

- Improve errors when is not passed all parameters

Version 0.3.0 - released 05/31/17
=================================
- Issues #31 - Using logging instead print
- Issues #26 - Implemented secure close ([Application issue 29](https://github.com/PedalPi/Application/issues/29) version 0.3.0)
- Issues #27 - Rename zeroconf device name

- Issue #31 - Using logging instead print
- Issue #26 - Implemented secure close ([Application issue 29](https://github.com/PedalPi/Application/issues/29) version 0.3.0)
- Issue #27 - Rename zeroconf device name
- Improve Component Data documentation
- Fix '#' problem when request plugin data
- Issue #40 - Add support for plugins manager v0.5.0 and Application v0.3.0

- Now using PluginsManager notification implementation (``with observer:``)

- Issue #37 - Banks swap -> Bank move

Version 0.2.0 - released 05/13/17
=================================

- Initial release
19 changes: 11 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The registration must occur before application initialization (``application.sta
application = Application(path_data="data/", address='localhost')

from webservice.webservice import WebService
application.register(WebService(application, port))
application.register(WebService(application, port=3000))

2. Initialization of the web server
+++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -122,7 +122,7 @@ look like the following code:
application = Application(path_data="data/", address='localhost')

from webservice.webservice import WebService
application.register(WebService(application, port))
application.register(WebService(application, port=3000))

application.start()

Expand Down Expand Up @@ -163,17 +163,20 @@ Maintenance
Documentation
*************

Is necessary to install `nodejs`_.

.. _nodejs: https://nodejs.org/en/

.. code-block:: bash

# Installing dependencies
npm install -g aglio
make install-docs-requirements

# Generate doc
cd docs/
aglio -i documentation.apib --theme-variables streak --theme-template triple -o index.html
make docs

# View documentation
firefox index.html
make docs-see

Test
****
Expand All @@ -185,5 +188,5 @@ Test

coverage3 run --source=webservice wstest/config.py test
coverage3 report
coverage3 html
firefox htmlcov/index.html
make test-details

213 changes: 133 additions & 80 deletions docs/index.html

Large diffs are not rendered by default.

103 changes: 85 additions & 18 deletions docs/section/authentication.apib
Original file line number Diff line number Diff line change
@@ -1,39 +1,106 @@
Authentication has two purposes: Control access and obtaining token request identifier
To access API methods, you must be authenticated. The authenticatetion is based on [JWT technology](http://jwt.io).

## Control access [/?]
## Control access [/auth]

Not implemented
### Authenticate [POST]

## 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.

When a connection is established with `http://pedalpi.local/ws`, a `TOKEN message` (`"type": "TOKEN"`) returns a **uuid4** for the client.
For auth, send the `username` and the `password` as a json object. In this
current version, exists only a `username`: `pedal pi`

```json
{
"value": "{token uuid4}",
"type": "TOKEN"
"username": "pedal pi",
"password": "pedal pi",
}
```

It's necessary that all requests add the following header parameter.
::: warning
The initial password is `pedal pi`. ~Please, on the first login, change
the password~ (in development)!
:::

If the data is correct, will be returned the **auth token**.
You need send it in every request. See a example in the [next section](#authentication-auth-token).

::: warning
The token has a expiration of **7 days** from login response time. If the token has
expired, is necessary request auth to obtains a new token.
:::

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

+ Body

{
"username": "pedal pi",
"password": "pedal pi",
}

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

{"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1MjE5ODM1NDZ9.MKT1XRgqa68ADIdH1ro0MkIWwh9mXrNPjz5q5aUhFKc"}

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

{"error": "Invalid username or password"}

## How to use auth token [/something]

In the requests, is necessary send the auth token in the header with the following stard:

```http
x-xsrf-token: {token uuid4}
```
Authorization: bearer <token>
```

### Example request [GET]

It's a example request for a random address
::: note
The Authorization code error is `401`.

+ Request 200 (application/json; charset=UTF-8)
See the possible errors in right selecting a request.
:::

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

x-xsrf-token: {token uuid4}

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

anything
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 standard `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"}
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"}
2 changes: 1 addition & 1 deletion docs/section/bank_get.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"index": 1, "pedalboards": [{"connections": [{"input": {"index": 0, "effect": 0, "symbol": "in"}, "output": {"index": 0, "symbol": "capture_1"}}, {"input": {"index": 0, "symbol": "playback_1"}, "output": {"index": 1, "effect": 0, "symbol": "out"}}], "data": {"pedalpi-apk": {"effectPositions": [{"y": 91.4995002746582, "x": 159.74801635742188}]}}, "effects": [{"active": true, "plugin": "http://drobilla.net/plugins/fomp/cs_chorus1", "technology": "lv2", "params": [{"index": 2, "value": 7.5, "minimum": 0.0, "maximum": 30.0, "symbol": "delay"}, {"index": 3, "value": 0.20000000298023224, "minimum": 0.003000000026077032, "maximum": 10.0, "symbol": "mod_freq_1"}, {"index": 4, "value": 2.5, "minimum": 0.0, "maximum": 10.0, "symbol": "mod_amp_1"}, {"index": 5, "value": 0.800000011920929, "minimum": 0.009999999776482582, "maximum": 30.0, "symbol": "mod_freq_2"}, {"index": 6, "value": 0.75, "minimum": 0.0, "maximum": 3.0, "symbol": "mod_amp_2"}]}], "name": "Empty pedalboard"}], "name": "My awesome bank"}
{"index": 1, "pedalboards": [{"connections": [{"type": "audio", "input": {"index": 0, "effect": 0, "symbol": "in"}, "output": {"index": 0, "symbol": "capture_1"}}, {"type": "audio", "input": {"index": 0, "symbol": "playback_1"}, "output": {"index": 1, "effect": 0, "symbol": "out"}}], "data": {"pedalpi-apk": {"effectPositions": [{"y": 91.4995002746582, "x": 159.74801635742188}]}}, "effects": [{"active": true, "plugin": "http://drobilla.net/plugins/fomp/cs_chorus1", "technology": "lv2", "params": [{"index": 2, "value": 7.5, "minimum": 0.0, "maximum": 30.0, "symbol": "delay"}, {"index": 3, "value": 0.20000000298023224, "minimum": 0.003000000026077032, "maximum": 10.0, "symbol": "mod_freq_1"}, {"index": 4, "value": 2.5, "minimum": 0.0, "maximum": 10.0, "symbol": "mod_amp_1"}, {"index": 5, "value": 0.800000011920929, "minimum": 0.009999999776482582, "maximum": 30.0, "symbol": "mod_freq_2"}, {"index": 6, "value": 0.75, "minimum": 0.0, "maximum": 3.0, "symbol": "mod_amp_2"}]}], "name": "Empty pedalboard"}], "name": "My awesome bank"}
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
16 changes: 14 additions & 2 deletions docs/section/component_data.apib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
In addition to the possibility of persisting additional data for a particular pedalboard, it is possible to persist isolated data, that is, they do not share the same storage space with pedalboards.
In addition to the possibility of [persisting additional data for a specific pedalboard](#pedalboard-data-management), it's possible to persist isolated data, that is, they do not share the same storage space with pedalboards.

## Manage data [/data/{key}]

Expand All @@ -14,12 +14,18 @@ It is expected, although not mandatory, that data from a component using this AP
Get the current data persisted for the informed `key`. If any data has previously persisted, returns a empty dict (`{}`).

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

Authorization: bearer <auth token>
+ Response 200
+ Body

{"a key": "a value"}

+ Request No data previously saved (application/json; charset=UTF-8)
+ Request no data previously saved (application/json; charset=UTF-8)
+ Headers

Authorization: bearer <auth token>
+ Response 200
+ Body

Expand All @@ -36,6 +42,9 @@ When adding a new data, remember to stick with what has already been persisted.
:::

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

Authorization: bearer <auth token>
+ Body

{"current-data": {"name": "test"}, {"value": [1, 2, 3]}}
Expand All @@ -51,4 +60,7 @@ Removes the current data persisted for the informed `key`.
:::

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

Authorization: bearer <auth token>
+ Response 200
Loading