From 4bde2de9cb6e9c2753c6eb18a523b2c92f341827 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Tue, 28 Jul 2020 20:55:41 -0300 Subject: oauth: Extract the web server address from the setup URL This lets the OAUTH module be used for other localhost ports too. Signed-off-by: Jason Gunthorpe --- cloud_mdir_sync/oauth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloud_mdir_sync/oauth.py b/cloud_mdir_sync/oauth.py index 385e0e8..dfa1987 100644 --- a/cloud_mdir_sync/oauth.py +++ b/cloud_mdir_sync/oauth.py @@ -13,6 +13,8 @@ import aiohttp.web import oauthlib import oauthlib.oauth2 +import urllib.parse + if TYPE_CHECKING: from . import config @@ -46,7 +48,8 @@ class WebServer(object): async def go(self): self.runner = aiohttp.web.AppRunner(self.web_app) await self.runner.setup() - site = aiohttp.web.TCPSite(self.runner, '127.0.0.1', 8080) + url = urllib.parse.urlparse(self.url) + site = aiohttp.web.TCPSite(self.runner, url.hostname, url.port) await site.start() async def close(self): -- cgit v1.2.3