Browse Source
Finish documentation work for 2018.8.1
Finish documentation work for 2018.8.1
* Added a delete method for the user_api * Added a password strength verification * Allow the registration of a user to include a desired password * Raised validation errors instead of value errors * Added a 404 error handler to return a json APIMessage alongside the 404merge-requests/1/head
Drew Short
6 years ago
24 changed files with 451 additions and 34 deletions
-
1server/Pipfile
-
11server/Pipfile.lock
-
6server/README.md
-
4server/atheneum/__init__.py
-
6server/atheneum/api/authentication_api.py
-
25server/atheneum/api/model.py
-
36server/atheneum/api/user_api.py
-
11server/atheneum/errors.py
-
26server/atheneum/service/authentication_service.py
-
10server/atheneum/service/patch_service.py
-
11server/atheneum/service/user_service.py
-
4server/atheneum/utility/json_utility.py
-
98server/documentation/api/authentication.rst
-
9server/documentation/api/index.rst
-
158server/documentation/api/user.rst
-
1server/documentation/conf.py
-
4server/documentation/index.rst
-
4server/documentation/introduction.rst
-
2server/manage.py
-
1server/run_tests.sh
-
2server/tests/api/test_authentication_api.py
-
44server/tests/api/test_user_api.py
-
2server/tests/conftest.py
-
9server/tests/service/test_patch_service.py
@ -0,0 +1,98 @@ |
|||||
|
Authentication API |
||||
|
================== |
||||
|
|
||||
|
.. http:post:: /auth/login |
||||
|
|
||||
|
Authenticate with the server and receive a userToken for requests. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
POST /auth/login HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Basic <Base64 Encoded Basic Auth> |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"creationTime": "2018-07-29T11:59:29-05:00", |
||||
|
"enabled": true, |
||||
|
"token": "b94cf5c7-cddc-4610-9d4c-6b8e04088ae8", |
||||
|
"version": 0 |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged in |
||||
|
:statuscode 401: authorization failed |
||||
|
|
||||
|
.. http:post:: /auth/bump |
||||
|
|
||||
|
Bump user login information. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
POST /auth/bump HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"lastLoginTime": "2018-07-29T12:15:51-05:00" |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user last_login_time successfully bumped |
||||
|
:statuscode 401: authorization failed |
||||
|
|
||||
|
.. http:post:: /auth/logout |
||||
|
|
||||
|
Logout a user and remove the provided userToken from valid tokens. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
POST /auth/logout HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"success": true |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged out |
||||
|
:statuscode 401: authorization failed |
@ -0,0 +1,9 @@ |
|||||
|
Atheneum API documentation |
||||
|
========================== |
||||
|
|
||||
|
.. toctree:: |
||||
|
:maxdepth: 2 |
||||
|
:caption: Contents: |
||||
|
|
||||
|
authentication |
||||
|
user |
@ -0,0 +1,158 @@ |
|||||
|
User API |
||||
|
======== |
||||
|
|
||||
|
.. http:get:: /user/(str:user_name) |
||||
|
|
||||
|
Find a user by name. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
GET /user/atheneum_administrator HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"creationTime": "2018-07-29T11:58:17-05:00", |
||||
|
"lastLoginTime": "2018-07-29T12:43:27-05:00", |
||||
|
"name": "atheneum_administrator", |
||||
|
"role": "ADMIN", |
||||
|
"version": 0 |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged in |
||||
|
:statuscode 401: authorization failed |
||||
|
:statuscode 404: user doesn't exist |
||||
|
|
||||
|
.. http:patch:: /user/(str:user_name) |
||||
|
|
||||
|
Patch a user. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
PATCH /user/atheneum_administrator HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"lastLoginTime": "2019-07-29T12:43:27-05:00", |
||||
|
"version": 0 |
||||
|
} |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"creationTime": "2018-07-29T11:58:17-05:00", |
||||
|
"lastLoginTime": "2019-07-29T12:43:27-05:00", |
||||
|
"name": "atheneum_administrator", |
||||
|
"role": "ADMIN", |
||||
|
"version": 1 |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:reqheader Content-Type: application/json |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged in |
||||
|
:statuscode 400: an issue in the payload was discovered |
||||
|
:statuscode 401: authorization failed |
||||
|
:statuscode 404: user doesn't exist |
||||
|
|
||||
|
.. http:post:: /user/ |
||||
|
|
||||
|
Register a new user with the service. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
POST /user/ HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"name": "test_user", |
||||
|
"password": "JvZ9bm79", |
||||
|
"role": "USER" |
||||
|
} |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"creationTime": "2018-07-29T14:16:48-05:00", |
||||
|
"name": "test_user", |
||||
|
"role": "USER", |
||||
|
"version": 0 |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:reqheader Content-Type: application/json |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged in |
||||
|
:statuscode 400: an issue in the payload was discovered |
||||
|
:statuscode 401: authorization failed |
||||
|
|
||||
|
.. http:delete:: /user/(str:user_name) |
||||
|
|
||||
|
Register a new user with the service. |
||||
|
|
||||
|
**Example request**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
DELETE /user/test_user HTTP/1.1 |
||||
|
Host: example.tld |
||||
|
Accept: application/json |
||||
|
Authorization: Token <Base64(user:userToken)> |
||||
|
|
||||
|
**Example response**: |
||||
|
|
||||
|
.. sourcecode:: http |
||||
|
|
||||
|
HTTP/1.1 200 OK |
||||
|
Vary: Accept |
||||
|
Content-Type: application/json |
||||
|
|
||||
|
{ |
||||
|
"message": "Successfully Deleted", |
||||
|
"success": true |
||||
|
} |
||||
|
|
||||
|
:reqheader Accept: the response content type depends on :mailheader:`Accept` header |
||||
|
:reqheader Authorization: The encoded basic authorization |
||||
|
:resheader Content-Type: this depends on :mailheader:`Accept` header of request |
||||
|
:statuscode 200: user successfully logged in |
||||
|
:statuscode 401: authorization failed |
||||
|
:statuscode 404: user doesn't exist |
@ -0,0 +1,4 @@ |
|||||
|
Introduction To Atheneum |
||||
|
======================== |
||||
|
|
||||
|
TODO |
Write
Preview
Loading…
Cancel
Save
Reference in new issue