hmm fallback tenant

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-02-24 14:41:00 +01:00
parent 905ae00e02
commit c6f8290ca1
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -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()