Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vui current state rebased #2752

Merged
merged 45 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
667e3dc
WIP: Endpoints integrated directly with platform_web_service.py. This…
davidraker May 4, 2021
288d8f4
WIP: RPC endpoints and all those higher in the hierarchy are working.…
davidraker May 20, 2021
5c560c3
WIP: Added _rpc method, some devices work, and topic_tree.py
davidraker May 28, 2021
49ce7be
WIP: TopicTree working and devices resolving routes. GET of values ma…
davidraker Jun 2, 2021
dc4f9a4
WIP: Fixed missing values in topic_tree.get_children_dict() when call…
davidraker Jun 2, 2021
4cb685f
WIP: Fixed issue with leafless branches after pruning tree in case of…
davidraker Jun 2, 2021
921959d
WIP: Volttron UI endpoints work to date.
davidraker May 4, 2021
d9b961f
WIP: RPC endpoints and all those higher in the hierarchy are working.…
davidraker May 20, 2021
ff41cc5
WIP: Added _rpc method, some devices work, and topic_tree.py
davidraker May 28, 2021
e4ea386
WIP: TopicTree working and devices resolving routes. GET of values ma…
davidraker Jun 2, 2021
08577dd
WIP: Fixed missing values in topic_tree.get_children_dict() when call…
davidraker Jun 2, 2021
8b473ce
WIP: Fixed issue with leafless branches after pruning tree in case of…
davidraker Jun 2, 2021
a8cc17f
Added path information to import statement in actuator/agent.py so th…
davidraker Jun 11, 2021
9c14a3d
WIP: Platforms/devices endpoints and topic_tree classes working.
davidraker Jun 11, 2021
8a96b98
historian_apis
subasah Jul 9, 2021
44b1fc1
Updated topic_tree to work outside of vui_endpoints.
davidraker Jul 2, 2021
c81ac9c
Updated 501 responses.
davidraker Jul 2, 2021
ff03897
Added enclosing "route_options" dict to responses which have options …
davidraker Jul 2, 2021
d3b1f51
Corrected incorrect argument in jwt.decode call.
davidraker Jul 9, 2021
549be4f
Corrected import of Exceptions from driver and actuator
davidraker Jul 9, 2021
5d4351e
WIP: Tests and fixes
davidraker Jul 13, 2021
4260447
WIP: Beginning pubsub endpoints.
davidraker Jul 2, 2021
953bb9d
WIP: Minimal working pubsub GET implementation. Not production ready.
davidraker Jul 9, 2021
7be6d7f
Tests and corrections.
davidraker Aug 18, 2021
2860224
Removed unnecessary changes to actuator agent.
davidraker Aug 18, 2021
0628d44
Added tests and fixed some errors.
davidraker Sep 2, 2021
a6bf883
Merge branch 'VOLTTRON:main' into vui_current_state_rebased
davidraker Sep 3, 2021
d1995b6
Added validation for regex and tag query parameters.
davidraker Sep 17, 2021
0321bb7
Merge branch 'vui_current_state_rebased' of github.com:davidraker/vol…
davidraker Sep 17, 2021
d51c561
Fixed topic routes returned by historians endpoints.
davidraker Oct 15, 2021
b54f07a
Merge remote-tracking branch 'origin/develop' into vui_current_state_…
davidraker Oct 16, 2021
473841f
Added documenation for web-api
davidraker Sep 3, 2021
04c7e66
WIP: Documentation update.
davidraker Sep 17, 2021
8e4b249
Added menu link to index.rst
davidraker Oct 12, 2021
112fe15
Added documentation for VUI API.
davidraker Nov 23, 2021
2717147
Separated message and headers in pubsub publishing.
davidraker Nov 23, 2021
2e5ddb6
Merge branch 'develop' into vui_current_state_rebased
davidraker Dec 13, 2021
6c80eac
Merge branch 'develop' into vui_current_state_rebased
davidraker Jan 14, 2022
7d4a200
Added a decorator to handle authentication and generic exception hand…
davidraker Sep 3, 2021
8f7ee3b
Added @endpoint decorator to remaining functions except pubsub. Corre…
davidraker Dec 4, 2021
5991c95
Added installation instructions to web API documentation.
davidraker Dec 10, 2021
32a06ee
Merge branch 'develop' into vui_current_state_rebased
davidraker Jan 21, 2022
8a9a7ae
Added treelib to requirements.py for web target.
davidraker Jan 24, 2022
87c710c
Removed extraneous get() in vui_endpoints.py
davidraker Jan 24, 2022
f41ecb7
Fixed authentication in tests for VUI API.
davidraker Jan 24, 2022
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
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ at our bi-weekly office-hours and on Slack. To be invited to office-hours or sla
platform-features/control/index
platform-features/config-store/configuration-store
platform-features/security/volttron-security
platform-features/web-api/introduction


.. toctree::
Expand Down
104 changes: 104 additions & 0 deletions docs/source/platform-features/web-api/agent-endpoints.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
================
Agents Endpoints
================

Agents endpoints expose functionality associated with applications
running on a VOLTTRON platform.

Agents endpoints currently include:

* `RPC <rpc-endpoints.html>`_: Endpoints allowing, discovery, inspection, and calling of remote procedure calls to agents running on the platform.

.. attention::
All Agent endpoints require a JWT bearer token obtained through the
``POST /authenticate`` or ``PUT /authenticate`` endpoints.

--------------

GET /platforms/:platform/agents
===============================

Return routes for the agents installed on the platform.

Accepts a two query parameters:

* ``agent-state`` accepts one of three string values:

- *"running"* (default): Returns only those agents which are currently running.
- *"installed"*: Returns all installed agents.
- *"packaged"*: Returns filenames of packaged agents on the platform which can be installed.
* ``include-hidden`` (default=False): When True, includes system agents which would not normally be displayed by vctl status.

Request:
--------

- Authorization: ``BEARER <jwt_access_token>``

Response:
---------

* **With valid BEARER token on success:** ``200 OK``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"route_options": {
"<vip_identity>": "/platforms/:platform/agents/:vip_identity",
"<vip_identity>": "/platforms/:platform/agents/:vip_identity"
}
}

* **With valid BEARER token on failure:** ``400 Bad Request``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"error": "<Error Message>"
}

* **With invalid BEARER token:** ``401 Unauthorized``

------------------------------------------------------------------------------------------

GET /platforms/:platform/agents/:vip-identity
=============================================

Return routes for the supported endpoints for an agent installed on the platform.
Currently implemented endpoints include `RPC <rpc-endpoints.html>`_.

Request:
--------

- Authorization: ``BEARER <jwt_access_token>``

Response:
---------

* **With valid BEARER token on success:** ``200 OK``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"route_options": {
"<vip_identity>": "/platforms/:platform/agents/:vip_identity/<endpoint1_name>",
"<vip_identity>": "/platforms/:platform/agents/:vip_identity/<endpoint2_name>"
}
}

* **With valid BEARER token on failure:** ``400 Bad Request``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"error": "<Error Message>"
}

* **With invalid BEARER token:** ``401 Unauthorized``
113 changes: 113 additions & 0 deletions docs/source/platform-features/web-api/authentication-endpoints.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.. _Authentication-Endpoints:

========================
Authentication EndPoints
========================

The VOLTTRON Web API requires the use of bearer tokens to access resources. These tokens
are JSON Web Tokens (JWT) and are provided by the two ``/authenticate`` endpoints (``POST``
and ``PUT``). Two classes of token are provided to the user:

- Refresh Tokens:
Refresh tokens are long-lived, and used can be used to obtain a new short-lived access
token. Refresh tokens are obtained by providing a valid username and password to the
``POST /authenticate`` endpoint. The refresh token SHOULD be kept secure on the
client side, and SHOULD NOT be provided to API call other than to
``PUT /authenticate``.

- Access Tokens:
An access token are short-lived tokens required to obtain resources or services provided
by other API endpoints. The access token is obtained using the ``PUT /authenticate``
endpoint. For convenience, an inital access token is provided by the
``POST /authenticate`` endpoint as well, but as use the ``POST`` method requires
sending credentials to the server, this should only be used on the first call, with
``PUT`` being used thereafter to obtain new access tokens until the refresh token has
also expired.

.. note:: Authentication begins by obtaining a JWT bearer refresh token from the
``POST /authenticate`` endpoint. An initial access token is provided by this endpoint
as well. Subsequent access tokens are then obtained by providing the refresh token to the
``PUT /authenticate`` endpoint without resending of credentials.

----------------------------------------------------------------------------

POST /authenticate
==================

Provide authentication credentials to receive refresh token.

The user provides a username and password in the request body. If authentication succeeds,
the endpoint will returna a JWT bearer refresh token with user’s claims. An initial access
token is also returned. The refresh token can then be provided to ``PUT /authenticate``
to obtain new short-lived access tokens, as needed, without sending the username and
password again until the refresh token expires.

Request:
--------
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"username": "<username>",
"password": "<password>"
}

Response:
---------

* **With valid username and password:** ``200 OK``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"refresh_token": "<jwt_refresh_token>",
"access_token": "<jwt_access_token>"
}

* **With invalid username and password:** ``401 Unauthorized``

--------------

PUT /authenticate
=================

Renew access token.

The user provides a valid refresh token (provided by ``POST /authenticate``) in the
Authorization header to obtain a fresh access token. A current access token MAY also
be provided, as needed, in the request body to keep open any existing subscriptions.
All subsequent requests to any endpoint should include the new token, and the old
access token should be discarded.

Request:
--------

- Content Type: ``application/json``
- Authorization: ``BEARER <jwt_refresh_token>``
- Body (optional):

.. code-block:: JSON

{
"current_access_token": "<jwt_access_token>"
}

Response:
---------

* **With valid refresh token:** ``200 OK``
- Content Type: ``application/json``
- Body:

.. code-block:: JSON

{
"access_token": "<new_jwt_access_token>"
}

* **With invalid or mismatched username, password, or token:**
``401 Unauthorized``
Loading