authentik.admin.utils

authentik admin utils

 1"""authentik admin utils"""
 2
 3from authentik.admin.models import SystemSettings
 4from authentik.lib.config import CONFIG
 5from authentik.root.cache import in_memory_cache
 6
 7
 8@in_memory_cache(key=lambda: None, timeout=CONFIG.get_int("cache.timeout_system_settings", 30))
 9def get_system_settings() -> SystemSettings:
10    """Get the system settings. The returned object is shared, don't mutate it."""
11    return SystemSettings.objects.get(pk=True)
12
13
14def normalize_base_url(value: str | None) -> str:
15    """Normalize a configured base URL: strip whitespace and trailing slashes."""
16    return (value or "").strip().rstrip("/")
@in_memory_cache(key=lambda: None, timeout=CONFIG.get_int('cache.timeout_system_settings', 30))
def get_system_settings() -> authentik.admin.models.SystemSettings:
 9@in_memory_cache(key=lambda: None, timeout=CONFIG.get_int("cache.timeout_system_settings", 30))
10def get_system_settings() -> SystemSettings:
11    """Get the system settings. The returned object is shared, don't mutate it."""
12    return SystemSettings.objects.get(pk=True)

Get the system settings. The returned object is shared, don't mutate it.

def normalize_base_url(value: str | None) -> str:
15def normalize_base_url(value: str | None) -> str:
16    """Normalize a configured base URL: strip whitespace and trailing slashes."""
17    return (value or "").strip().rstrip("/")

Normalize a configured base URL: strip whitespace and trailing slashes.