Authentication
Manages authentication for Flask routes and application contexts.
- class auth.Scope(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Authentication scopes required for each API route.
Each user stores an
authmask
composite of scopes such that they may access any combination of API routes and access may be modified after user creation.Authentication scopes are NOT hierarchical, i.e. higher flag values do not include permissions inherited from lower values.
Each enum int flag value evaluates to powers of two, ascending with ordinal.
- ITEM_GET = 1
- ITEM_CREATE = 2
- ITEM_UPDATE = 4
- ITEM_DELETE = 8
- ITEMS_LIST = 16
- RESERVATION_GET = 32
- RESERVATION_CREATE = 64
- RESERVATION_UPDATE = 128
- RESERVATION_DELETE = 256
- RESERVATIONS_LIST = 512
- USER_GET = 1024
- USER_GET_AUTHMASK = 2048
- USER_CREATE = 4096
- USER_UPDATE = 8192
- USER_DELETE = 16384
- BOX_GET = 32768
- BOX_CREATE = 65536
- BOX_UPDATE = 131072
- BOX_DELETE = 262144
- BOXES_LIST = 524288
- THUMBNAIL_GET = 1048576
- THUMBNAIL_UPLOAD = 2097152
- THUMBNAIL_DELETE = 4194304
- auth.route_requires_auth(scope)
Function decorator for Flask routes which requires authentication by a user with the specified
auth.Scope
.- See also:
auth.require_auth()
for implementation and return details.
Example:
@app.route('/api/item/create') @auth.route_requires_auth(auth.Scope.ITEM_CREATE) def api_item_create(): ...
- auth.require_auth(req_authmask: Scope, api_key: str) None
Require authentication in the current context by a user with the specified
auth.Scope
(s), otherwise error.- See also:
auth.route_requires_auth()
for usage on Flask routes.- See also:
api_user_routes.api_user_create()
for how to create a user- See also:
api_user_routes.api_user_update()
for how to modify the authenticated scopes of an existing user- Returns:
None
if authenticated correctly,400
if API key was malformed,401
if API key was invalid,403
if user does not have required scope,500
if any other error while authenticating