-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from davidraker/docs
Docs
- Loading branch information
Showing
28 changed files
with
2,625 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:: javascript | ||
{ | ||
"username": "<username>", | ||
"password": "<password>" | ||
} | ||
Response: | ||
--------- | ||
|
||
* **With valid username and password:** ``200 OK`` | ||
- Content Type: ``application/json`` | ||
- Body: | ||
|
||
.. code-block:: javascript | ||
{ | ||
"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:: javascript | ||
{ | ||
"current_access_token": "<jwt_access_token>" | ||
} | ||
Response: | ||
--------- | ||
|
||
* **With valid refresh token:** ``200 OK`` | ||
- Content Type: ``application/json`` | ||
- Body: | ||
|
||
.. code-block:: javascript | ||
{ | ||
"access_token": "<new_jwt_access_token>" | ||
} | ||
* **With invalid or mismatched username, password, or token:** | ||
``401 Unauthorized`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- {{{ | ||
# ===----------------------------------------------------------------------=== | ||
# | ||
# Installable Component of Eclipse VOLTTRON | ||
# | ||
# ===----------------------------------------------------------------------=== | ||
# | ||
# Copyright 2022 Battelle Memorial Institute | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy | ||
# of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# ===----------------------------------------------------------------------=== | ||
# }}} | ||
|
||
# Configuration file for the Sphinx documentation builder. | ||
|
||
# -- Project information | ||
|
||
project = 'VOLTTRON Web Service' | ||
copyright = '2022, Pacific Northwest National Lab' | ||
author = 'Pacific Northwest National Lab' | ||
|
||
release = '0.2' | ||
version = '0.2.0-rc' | ||
|
||
# -- General configuration | ||
|
||
extensions = [ | ||
'sphinx.ext.duration', | ||
'sphinx.ext.doctest', | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.autosummary', | ||
'sphinx.ext.intersphinx', | ||
] | ||
|
||
intersphinx_mapping = { | ||
'python': ('https://docs.python.org/3/', None), | ||
'sphinx': ('https://www.sphinx-doc.org/en/master/', None), | ||
} | ||
intersphinx_disabled_domains = ['std'] | ||
|
||
templates_path = ['_templates'] | ||
|
||
# -- Options for HTML output | ||
|
||
html_theme = 'sphinx_rtd_theme' | ||
|
||
# -- Options for EPUB output | ||
# epub_show_urls = 'footnote' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.