admin: use matching environment for system API

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2023-01-01 23:58:12 +01:00
parent c810628fe3
commit e9d52282b7
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View File

@ -16,6 +16,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
from authentik.core.api.utils import PassiveSerializer 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.apps import MANAGED_OUTPOST
from authentik.outposts.models import Outpost from authentik.outposts.models import Outpost
@ -69,7 +70,7 @@ class SystemSerializer(PassiveSerializer):
return { return {
"python_version": python_version, "python_version": python_version,
"gunicorn_version": ".".join(str(x) for x in gunicorn_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(), "architecture": platform.machine(),
"platform": platform.platform(), "platform": platform.platform(),
"uname": " ".join(platform.uname()), "uname": " ".join(platform.uname()),

View File

@ -48,14 +48,14 @@ def get_apps():
def get_env() -> str: def get_env() -> str:
"""Get environment in which authentik is currently running""" """Get environment in which authentik is currently running"""
if SERVICE_HOST_ENV_NAME in os.environ:
return "kubernetes"
if "CI" in os.environ: if "CI" in os.environ:
return "ci" return "ci"
if Path("/tmp/authentik-mode").exists(): # nosec
return "compose"
if CONFIG.y_bool("debug"): if CONFIG.y_bool("debug"):
return "dev" 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: if "AK_APPLIANCE" in os.environ:
return os.environ["AK_APPLIANCE"] return os.environ["AK_APPLIANCE"]
return "custom" return "custom"