|
@ -21,7 +21,8 @@ AUTH_BLUEPRINT = Blueprint( |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/login', methods=['POST']) |
|
|
@AUTH_BLUEPRINT.route('/login', methods=['POST']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def login() -> APIResponse: |
|
|
def login() -> APIResponse: |
|
|
""" |
|
|
""" |
|
|
Get a token for continued authentication. |
|
|
Get a token for continued authentication. |
|
@ -34,7 +35,8 @@ def login() -> APIResponse: |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/bump', methods=['POST']) |
|
|
@AUTH_BLUEPRINT.route('/bump', methods=['POST']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def login_bump() -> APIResponse: |
|
|
def login_bump() -> APIResponse: |
|
|
""" |
|
|
""" |
|
|
Update the user last seen timestamp. |
|
|
Update the user last seen timestamp. |
|
@ -47,7 +49,8 @@ def login_bump() -> APIResponse: |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/logout', methods=['POST']) |
|
|
@AUTH_BLUEPRINT.route('/logout', methods=['POST']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def logout() -> APIResponse: |
|
|
def logout() -> APIResponse: |
|
|
""" |
|
|
""" |
|
|
Logout and delete a token. |
|
|
Logout and delete a token. |
|
@ -60,10 +63,11 @@ def logout() -> APIResponse: |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/token', methods=['GET']) |
|
|
@AUTH_BLUEPRINT.route('/token', methods=['GET']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def get_tokens() -> APIResponse: |
|
|
def get_tokens() -> APIResponse: |
|
|
""" |
|
|
""" |
|
|
Get a list of all tokens for the current user |
|
|
|
|
|
|
|
|
Get a list of all tokens for the current user. |
|
|
|
|
|
|
|
|
:return: a paginated list of user tokens |
|
|
:return: a paginated list of user tokens |
|
|
""" |
|
|
""" |
|
@ -76,10 +80,12 @@ def get_tokens() -> APIResponse: |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/token', methods=['POST']) |
|
|
@AUTH_BLUEPRINT.route('/token', methods=['POST']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def create_token(): |
|
|
def create_token(): |
|
|
""" |
|
|
""" |
|
|
Create a new token with optional parameters |
|
|
|
|
|
|
|
|
Create a new token with optional parameters. |
|
|
|
|
|
|
|
|
note: String |
|
|
note: String |
|
|
enabled: Boolean |
|
|
enabled: Boolean |
|
|
expirationTime: DateTime |
|
|
expirationTime: DateTime |
|
@ -89,16 +95,18 @@ def create_token(): |
|
|
requested_token: UserToken = transformation_service.deserialize_model( |
|
|
requested_token: UserToken = transformation_service.deserialize_model( |
|
|
UserToken, request.json, options=['note', 'enabled', 'expirationTime']) |
|
|
UserToken, request.json, options=['note', 'enabled', 'expirationTime']) |
|
|
user_token = user_token_service.create( |
|
|
user_token = user_token_service.create( |
|
|
g.user, requested_token.note, requested_token.enabled, requested_token.expiration_time) |
|
|
|
|
|
|
|
|
g.user, requested_token.note, |
|
|
|
|
|
requested_token.enabled, requested_token.expiration_time) |
|
|
return APIResponse(user_token, 200) |
|
|
return APIResponse(user_token, 200) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/token/<token>', methods=['GET']) |
|
|
@AUTH_BLUEPRINT.route('/token/<token>', methods=['GET']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def get_token(token: str): |
|
|
def get_token(token: str): |
|
|
""" |
|
|
""" |
|
|
Retrieve a specific token for this user |
|
|
|
|
|
|
|
|
Retrieve a specific token for this user. |
|
|
|
|
|
|
|
|
:param token: The token to retrieve for this user |
|
|
:param token: The token to retrieve for this user |
|
|
:return: The token if it exists |
|
|
:return: The token if it exists |
|
@ -111,10 +119,11 @@ def get_token(token: str): |
|
|
|
|
|
|
|
|
@AUTH_BLUEPRINT.route('/token/<token>', methods=['DELETE']) |
|
|
@AUTH_BLUEPRINT.route('/token/<token>', methods=['DELETE']) |
|
|
@return_json |
|
|
@return_json |
|
|
@authentication_middleware.require(required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
|
|
|
|
|
|
@authentication_middleware.require( |
|
|
|
|
|
required_auth=Auth.BASIC, required_role=Role.USER) |
|
|
def delete_token(token: str): |
|
|
def delete_token(token: str): |
|
|
""" |
|
|
""" |
|
|
Delete a specific token for this user |
|
|
|
|
|
|
|
|
Delete a specific token for this user. |
|
|
|
|
|
|
|
|
:param token: The token to delete for this user |
|
|
:param token: The token to delete for this user |
|
|
:return: Nothing on success |
|
|
:return: Nothing on success |
|
|