mirror of
https://github.com/maubot/maubot
synced 2025-09-07 22:00:39 +00:00
parent
5337d4d98e
commit
332ad5ea52
13 changed files with 238 additions and 36 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue