From e9d52282b7fabde57e19c8c907e2335baf1aeba7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 1 Jan 2023 23:58:12 +0100 Subject: [PATCH] admin: use matching environment for system API Signed-off-by: Jens Langhammer --- authentik/admin/api/system.py | 3 ++- authentik/lib/utils/reflection.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index 18c379bc5..3f36c4730 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -16,6 +16,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from authentik.core.api.utils import PassiveSerializer +from authentik.lib.utils.reflection import get_env from authentik.outposts.apps import MANAGED_OUTPOST from authentik.outposts.models import Outpost @@ -69,7 +70,7 @@ class SystemSerializer(PassiveSerializer): return { "python_version": python_version, "gunicorn_version": ".".join(str(x) for x in gunicorn_version), - "environment": "kubernetes" if SERVICE_HOST_ENV_NAME in os.environ else "compose", + "environment": get_env(), "architecture": platform.machine(), "platform": platform.platform(), "uname": " ".join(platform.uname()), diff --git a/authentik/lib/utils/reflection.py b/authentik/lib/utils/reflection.py index c6ace7828..4e35688f9 100644 --- a/authentik/lib/utils/reflection.py +++ b/authentik/lib/utils/reflection.py @@ -48,14 +48,14 @@ def get_apps(): def get_env() -> str: """Get environment in which authentik is currently running""" - if SERVICE_HOST_ENV_NAME in os.environ: - return "kubernetes" if "CI" in os.environ: return "ci" - if Path("/tmp/authentik-mode").exists(): # nosec - return "compose" if CONFIG.y_bool("debug"): return "dev" + if SERVICE_HOST_ENV_NAME in os.environ: + return "kubernetes" + if Path("/tmp/authentik-mode").exists(): # nosec + return "compose" if "AK_APPLIANCE" in os.environ: return os.environ["AK_APPLIANCE"] return "custom"