From 519df6cfa613ff54b8b6e4f5fafc605061c4d58b Mon Sep 17 00:00:00 2001 From: "robin.hruska@teskalabs.com" Date: Thu, 7 Nov 2024 16:19:15 +0100 Subject: [PATCH] use tenant providers --- asab/web/tenant/service.py | 55 -------------------------------------- 1 file changed, 55 deletions(-) diff --git a/asab/web/tenant/service.py b/asab/web/tenant/service.py index c36a5de7..a2f52c11 100644 --- a/asab/web/tenant/service.py +++ b/asab/web/tenant/service.py @@ -62,58 +62,3 @@ def get_tenants(self) -> typing.Set[str]: def is_tenant_known(self, tenant: str) -> bool: return tenant in self.Tenants - - def locate_tenant(self, tenant_id): - if tenant_id in self.Tenants: - return tenant_id - elif self.TenantsTrusted: - self.Tenants.add(tenant_id) - return tenant_id - else: - return None - - - def get_tenants(self): - return list(self.Tenants) - - - def add_web_api(self, web_container): - from .web import TenantWebHandler - self.TenantWebHandler = TenantWebHandler(self.App, self, web_container) - - - async def _update_tenants(self, message_name=None): - new_tenants = set() - - if len(self.TenantUrl) > 0: - async with aiohttp.ClientSession() as session: - async with session.get(self.TenantUrl) as resp: - if resp.status == 200: - external_tenants = await resp.json() - else: - L.warning("Failed to load tenants.", struct_data={"url": self.TenantUrl}) - return - - new_tenants.update(external_tenants) - - if len(self._StaticTenants) > 0: - new_tenants.update(self._StaticTenants) - - if self.Tenants != new_tenants: - self.App.PubSub.publish("Tenants.change!") - self.Tenants = new_tenants - - -def _read_tenants_from_config() -> typing.Set[str]: - tenants = set() - for tenant_id in re.split(r"[,\s]+", Config.get("tenants", "ids"), flags=re.MULTILINE): - tenant_id = tenant_id.strip() - # Skip comments and empty lines - if len(tenant_id) == 0: - continue - if tenant_id[0] == '#': - continue - if tenant_id[0] == ';': - continue - tenants.add(tenant_id) - return tenants