From ca956aa70bf8e5c95cd4ca1bbf3976ddaff76df3 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Fri, 12 Jan 2024 02:58:41 +0100 Subject: [PATCH] web: fix system status being degraded when embedded outpost is disabled Signed-off-by: Marc 'risson' Schmitt --- authentik/admin/api/system.py | 6 ++++++ schema.yml | 4 ++++ web/src/admin/admin-overview/cards/SystemStatusCard.ts | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index d8d0f80b4..16637067a 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -13,6 +13,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from authentik.core.api.utils import PassiveSerializer +from authentik.lib.config import CONFIG from authentik.lib.utils.reflection import get_env from authentik.outposts.apps import MANAGED_OUTPOST from authentik.outposts.models import Outpost @@ -39,6 +40,7 @@ class SystemInfoSerializer(PassiveSerializer): runtime = SerializerMethodField() brand = SerializerMethodField() server_time = SerializerMethodField() + embedded_outpost_disabled = SerializerMethodField() embedded_outpost_host = SerializerMethodField() def get_http_headers(self, request: Request) -> dict[str, str]: @@ -77,6 +79,10 @@ class SystemInfoSerializer(PassiveSerializer): """Current server time""" return now() + def get_embedded_outpost_disabled(self, request: Request) -> bool: + """Whether the embedded outpost is disabled""" + return CONFIG.get_bool("outposts.disable_embedded_outpost", False) + def get_embedded_outpost_host(self, request: Request) -> str: """Get the FQDN configured on the embedded outpost""" outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST) diff --git a/schema.yml b/schema.yml index d0de034a6..c6522f96d 100644 --- a/schema.yml +++ b/schema.yml @@ -43495,8 +43495,12 @@ components: type: string description: Get the FQDN configured on the embedded outpost readOnly: true + embedded_outpost_disabled: + type: boolean + readOnly: true required: - brand + - embedded_outpost_disabled - embedded_outpost_host - http_headers - http_host diff --git a/web/src/admin/admin-overview/cards/SystemStatusCard.ts b/web/src/admin/admin-overview/cards/SystemStatusCard.ts index 7c6ac276c..ee5449fcf 100644 --- a/web/src/admin/admin-overview/cards/SystemStatusCard.ts +++ b/web/src/admin/admin-overview/cards/SystemStatusCard.ts @@ -22,7 +22,10 @@ export class SystemStatusCard extends AdminStatusCard { async getPrimaryValue(): Promise { this.now = new Date(); let status = await new AdminApi(DEFAULT_CONFIG).adminSystemRetrieve(); - if (status.embeddedOutpostHost === "" || !status.embeddedOutpostHost.includes("http")) { + if ( + !status.embeddedOutpostDisabled && + (status.embeddedOutpostHost === "" || !status.embeddedOutpostHost.includes("http")) + ) { // First install, ensure the embedded outpost host is set // also run when outpost host does not contain http // (yes it's called host and requires a URL, i know) @@ -51,7 +54,7 @@ export class SystemStatusCard extends AdminStatusCard { } getStatus(value: SystemInfo): Promise { - if (value.embeddedOutpostHost === "") { + if (!value.embeddedOutpostDisabled && value.embeddedOutpostHost === "") { this.statusSummary = msg("Warning"); return Promise.resolve({ icon: "fa fa-exclamation-triangle pf-m-warning",