|
@@ -134,11 +134,15 @@ def authRequired(func):
|
|
|
@wraps(func)
|
|
@wraps(func)
|
|
|
async def authWrapper(*args, **kwargs):
|
|
async def authWrapper(*args, **kwargs):
|
|
|
auth = request.authorization
|
|
auth = request.authorization
|
|
|
|
|
+ headers = request.headers
|
|
|
if ((auth is not None) and
|
|
if ((auth is not None) and
|
|
|
(auth.type == "basic") and
|
|
(auth.type == "basic") and
|
|
|
(auth.username in current_app.cache['devices']) and
|
|
(auth.username in current_app.cache['devices']) and
|
|
|
(compare_digest(auth.password, current_app.cache['devices'][auth.username]))):
|
|
(compare_digest(auth.password, current_app.cache['devices'][auth.username]))):
|
|
|
return await func(*args, **kwargs)
|
|
return await func(*args, **kwargs)
|
|
|
|
|
+ else if ((current_app.config['AUTH_HEADER'].lower() in headers) and
|
|
|
|
|
+ (headers[current_app.config['AUTH_HEADER'].lower()] == current_app.config['AUTH_SECRET'])):
|
|
|
|
|
+ return await func(*args, **kwargs)
|
|
|
else:
|
|
else:
|
|
|
abort(401)
|
|
abort(401)
|
|
|
return authWrapper
|
|
return authWrapper
|