From c6f8290ca1dab73e8f8b7bf33cb54ab1bed2ba2c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 24 Feb 2023 14:41:00 +0100 Subject: [PATCH] hmm fallback tenant Signed-off-by: Jens Langhammer --- authentik/tenants/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index 87da6c8f6..8acefbe34 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -1,4 +1,5 @@ """Tenant utilities""" +from functools import cache from typing import Any from django.db.models import F, Q @@ -11,7 +12,12 @@ from authentik.lib.config import CONFIG from authentik.tenants.models import Tenant _q_default = Q(default=True) -DEFAULT_TENANT = Tenant(domain="fallback") + + +@cache +def get_fallback_tenant(): + """Get fallback tenant""" + return Tenant(domain="fallback") def get_tenant_for_request(request: HttpRequest) -> Tenant: @@ -40,3 +46,6 @@ def context_processor(request: HttpRequest) -> dict[str, Any]: "sentry_trace": trace, "version": get_full_version(), } + + +DEFAULT_TENANT = get_fallback_tenant()