diff --git a/src/app/__init__.py b/src/app/__init__.py index 45ab4ae..9310790 100644 --- a/src/app/__init__.py +++ b/src/app/__init__.py @@ -7,3 +7,6 @@ logging.basicConfig( ) log = logging.getLogger(__name__) + +from .app import Application as BaseApplication + diff --git a/src/app/app.py b/src/app/app.py index 9acb190..f114c4d 100644 --- a/src/app/app.py +++ b/src/app/app.py @@ -1,7 +1,7 @@ import json import time import uuid - +import base64 import dataset from aiohttp import web @@ -20,22 +20,22 @@ class BaseApplication(web.Application): def __init__( self, - username=None, - password=None, + basic_username=None, + basic_password=None, cookie_name=None, session=None, *args, **kwargs, ): self.cookie_name = cookie_name or str(uuid.uuid4()) - self.username = username - self.password = password + self.basic_username = basic_username + self.basic_password = basic_password self.session = session or {} middlewares = kwargs.pop("middlewares", []) middlewares.append(self.request_middleware) middlewares.append(self.base64_auth_middleware) middlewares.append(self.session_middleware) - super().__init__(*args, **kwargs) + super().__init__(middlewares=middlewares,*args, **kwargs) def run(self, *args, **kwargs): web.run_app(self, *args, **kwargs) @@ -44,7 +44,7 @@ class BaseApplication(web.Application): return self.username == username and self.password == password @web.middleware - async def base64_auth_middleware(request, handler): + async def base64_auth_middleware(self, request, handler): auth_header = request.headers.get("Authorization") if not self.username: return await handler(request)