|
@@ -117,14 +117,7 @@ class AuthMiddleware:
|
|
|
for device in app.cache['devices']:
|
|
for device in app.cache['devices']:
|
|
|
if ((header == bytes('{}_{}'.format(app.config['AUTH_HEADER'].lower(), device), 'utf-8')) and
|
|
if ((header == bytes('{}_{}'.format(app.config['AUTH_HEADER'].lower(), device), 'utf-8')) and
|
|
|
(value == bytes(app.cache['devices'][device], 'utf-8'))):
|
|
(value == bytes(app.cache['devices'][device], 'utf-8'))):
|
|
|
- body = bytes('scope: {}'.format(pformat(scope, indent=1)), 'utf-8')
|
|
|
|
|
- await send({'type': 'http.response.start',
|
|
|
|
|
- 'status': 200,
|
|
|
|
|
- 'headers': [(b'content-length', bytes(str(len(body)), 'utf-8'))]})
|
|
|
|
|
- await send({'type': 'http.response.body',
|
|
|
|
|
- 'body': body,
|
|
|
|
|
- 'more_body': False})
|
|
|
|
|
-
|
|
|
|
|
|
|
+ scope['headers'][b'device']=bytes(device, 'utf-8')
|
|
|
return await self.app(scope, receive, send)
|
|
return await self.app(scope, receive, send)
|
|
|
# Paths "/openapi.json" and "/ui" do not require auth
|
|
# Paths "/openapi.json" and "/ui" do not require auth
|
|
|
if (('path' in scope) and
|
|
if (('path' in scope) and
|
|
@@ -304,6 +297,7 @@ async def amiGetVar(variable):
|
|
|
|
|
|
|
|
@app.route('/ami/auths')
|
|
@app.route('/ami/auths')
|
|
|
async def amiPJSIPShowAuths():
|
|
async def amiPJSIPShowAuths():
|
|
|
|
|
+ app.logger.warning(pformat(request.headers))
|
|
|
return successReply(app.cache['devices'])
|
|
return successReply(app.cache['devices'])
|
|
|
|
|
|
|
|
@app.route('/ami/aors')
|
|
@app.route('/ami/aors')
|