Add Matrix register/login API and full Matrix API proxy

(ref #19, #15)
This commit is contained in:
Tulir Asokan 2018-12-08 01:13:40 +02:00
parent 5337d4d98e
commit 332ad5ea52
13 changed files with 238 additions and 36 deletions

View file

@ -20,15 +20,20 @@ from aiohttp import web
from .responses import resp
from .auth import check_token
from .base import get_config
Handler = Callable[[web.Request], Awaitable[web.Response]]
@web.middleware
async def auth(request: web.Request, handler: Handler) -> web.Response:
if "/auth/" in request.path:
subpath = request.path.lstrip(get_config()["server.base_path"])
if subpath.startswith("/auth/") or subpath == "/logs" or subpath == "logs":
return await handler(request)
return check_token(request) or await handler(request)
err = check_token(request)
if err is not None:
return err
return await handler(request)
log = logging.getLogger("maubot.server")