ecf6234cfe
Since this is a change to the table schema for all services using the ping adapter, you will have to delete the tables relating to them. - elstat.blueprints: add incidents blueprint (WIP) - elstat.blueprints: add decorators.py - elstat.blueprints: add errors.py - elstat.manager: add incidents & incident_stages tables - run: add handler for ApiError
22 lines
577 B
Python
22 lines
577 B
Python
import hashlib
|
|
|
|
from .errors import ApiError
|
|
|
|
|
|
def auth_route(handler):
|
|
"""Declare an authenticated route."""
|
|
async def _handler(request, *args, **kwargs):
|
|
try:
|
|
pwhash = request.headers['Authorization']
|
|
except KeyError:
|
|
raise ApiError('no password provided', 403)
|
|
|
|
correct = request.app.cfg.PASSWORD
|
|
hashed = hashlib.sha256(correct.encode()).hexdigest()
|
|
|
|
if pwhash != hashed:
|
|
raise ApiError('invalid password', 403)
|
|
|
|
return await handler(request, *args, **kwargs)
|
|
|
|
return _handler
|