From e6cfa92f7be0c58587ddd5e4e6dfa9686a2cb933 Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Tue, 7 May 2024 17:46:57 +0500 Subject: [PATCH] change server to support authentication --- xconn/server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xconn/server.py b/xconn/server.py index 82cdcf8..d2cac0a 100644 --- a/xconn/server.py +++ b/xconn/server.py @@ -1,20 +1,22 @@ import aiohttp from aiohttp import web +from wampproto.auth import IServerAuthenticator from xconn.router import Router from xconn.acceptor import AIOHttpAcceptor class Server: - def __init__(self, router: Router): + def __init__(self, router: Router, authenticator: IServerAuthenticator = None): self.router = router + self.authenticator = authenticator async def _websocket_handler(self, request): ws = web.WebSocketResponse(protocols=["wamp.2.json", "wamp.2.cbor", "wamp.2.msgpack"]) # upgrade this connection to websocket. await ws.prepare(request) - acceptor = AIOHttpAcceptor() + acceptor = AIOHttpAcceptor(self.authenticator) base_session = await acceptor.accept(ws) self.router.attach_client(base_session)