From de9d483b9f75989f856c7f8fb67eff82a721ff4b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 10 Aug 2021 19:16:11 +0200 Subject: [PATCH] admin: add API to show embedded outpost status, add notice when its not configured properly Signed-off-by: Jens Langhammer --- authentik/admin/api/system.py | 10 ++++++++++ schema.yml | 4 ++++ web/src/locales/en.po | 17 +++++++++++++++++ web/src/locales/pseudo-LOCALE.po | 17 +++++++++++++++++ .../admin-overview/cards/SystemStatusCard.ts | 8 ++++++++ web/src/pages/outposts/OutpostListPage.ts | 11 ++++++++++- 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/authentik/admin/api/system.py b/authentik/admin/api/system.py index eb0c65d12..398ddee03 100644 --- a/authentik/admin/api/system.py +++ b/authentik/admin/api/system.py @@ -16,6 +16,8 @@ from rest_framework.response import Response from rest_framework.views import APIView from authentik.core.api.utils import PassiveSerializer +from authentik.outposts.managed import MANAGED_OUTPOST +from authentik.outposts.models import Outpost class RuntimeDict(TypedDict): @@ -38,6 +40,7 @@ class SystemSerializer(PassiveSerializer): runtime = SerializerMethodField() tenant = SerializerMethodField() server_time = SerializerMethodField() + embedded_outpost_host = SerializerMethodField() def get_http_headers(self, request: Request) -> dict[str, str]: """Get HTTP Request headers""" @@ -75,6 +78,13 @@ class SystemSerializer(PassiveSerializer): """Current server time""" return now() + def get_embedded_outpost_host(self, request: Request) -> str: + """Get the FQDN configured on the embeddded outpost""" + outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST) + if not outposts.exists(): + return "" + return outposts.first().config.authentik_host + class SystemView(APIView): """Get system information.""" diff --git a/schema.yml b/schema.yml index 4a6a9d360..ecb6f8ca8 100644 --- a/schema.yml +++ b/schema.yml @@ -29524,7 +29524,11 @@ components: type: string format: date-time readOnly: true + embedded_outpost_host: + type: string + readOnly: true required: + - embedded_outpost_host - http_headers - http_host - http_is_secure diff --git a/web/src/locales/en.po b/web/src/locales/en.po index 06b4a85a5..8e0de1eb2 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -611,6 +611,10 @@ msgstr "Check Username" msgid "Check access" msgstr "Check access" +#: src/pages/admin-overview/cards/SystemStatusCard.ts +msgid "Check outposts." +msgstr "Check outposts." + #: src/flows/stages/authenticator_duo/AuthenticatorDuoStage.ts msgid "Check status" msgstr "Check status" @@ -1365,6 +1369,10 @@ msgstr "Email stage" msgid "Email: Text field with Email type." msgstr "Email: Text field with Email type." +#: src/pages/admin-overview/cards/SystemStatusCard.ts +msgid "Embedded outpost is not configured correctly." +msgstr "Embedded outpost is not configured correctly." + #: #: #~ msgid "Enable" @@ -2252,6 +2260,10 @@ msgstr "Local" msgid "Log the currently pending user in." msgstr "Log the currently pending user in." +#: src/pages/outposts/OutpostListPage.ts +msgid "Logging in via {0}." +msgstr "Logging in via {0}." + #: src/pages/events/utils.ts msgid "Login" msgstr "Login" @@ -4744,6 +4756,7 @@ msgstr "Wait (max)" msgid "Wait (min)" msgstr "Wait (min)" +#: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/events/RuleForm.ts @@ -4759,6 +4772,10 @@ msgstr "Warning: Policy is not assigned." msgid "Warning: Provider not assigned to any application." msgstr "Warning: Provider not assigned to any application." +#: src/pages/outposts/OutpostListPage.ts +msgid "Warning: authentik Domain is not configured, authentication will not work." +msgstr "Warning: authentik Domain is not configured, authentication will not work." + #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts msgid "WebAuthn Authenticators" msgstr "WebAuthn Authenticators" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 4fbfb1470..1d9134d36 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -607,6 +607,10 @@ msgstr "" msgid "Check access" msgstr "" +#: src/pages/admin-overview/cards/SystemStatusCard.ts +msgid "Check outposts." +msgstr "" + #: src/flows/stages/authenticator_duo/AuthenticatorDuoStage.ts msgid "Check status" msgstr "" @@ -1357,6 +1361,10 @@ msgstr "" msgid "Email: Text field with Email type." msgstr "" +#: src/pages/admin-overview/cards/SystemStatusCard.ts +msgid "Embedded outpost is not configured correctly." +msgstr "" + #: #: #~ msgid "Enable" @@ -2244,6 +2252,10 @@ msgstr "" msgid "Log the currently pending user in." msgstr "" +#: src/pages/outposts/OutpostListPage.ts +msgid "Logging in via {0}." +msgstr "" + #: src/pages/events/utils.ts msgid "Login" msgstr "" @@ -4729,6 +4741,7 @@ msgstr "" msgid "Wait (min)" msgstr "" +#: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/admin-overview/cards/SystemStatusCard.ts #: src/pages/events/RuleForm.ts @@ -4744,6 +4757,10 @@ msgstr "" msgid "Warning: Provider not assigned to any application." msgstr "" +#: src/pages/outposts/OutpostListPage.ts +msgid "Warning: authentik Domain is not configured, authentication will not work." +msgstr "" + #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts msgid "WebAuthn Authenticators" msgstr "" diff --git a/web/src/pages/admin-overview/cards/SystemStatusCard.ts b/web/src/pages/admin-overview/cards/SystemStatusCard.ts index 861d24c68..eeb04e768 100644 --- a/web/src/pages/admin-overview/cards/SystemStatusCard.ts +++ b/web/src/pages/admin-overview/cards/SystemStatusCard.ts @@ -16,6 +16,14 @@ export class SystemStatusCard extends AdminStatusCard { } getStatus(value: System): Promise { + if (value.embeddedOutpostHost === "") { + this.header = t`Warning`; + return Promise.resolve({ + icon: "fa fa-exclamation-triangle pf-m-warning", + message: html`${t`Embedded outpost is not configured correctly.`} + ${t`Check outposts.`}`, + }); + } if (!value.httpIsSecure && document.location.protocol === "https:") { this.header = t`Warning`; return Promise.resolve({ diff --git a/web/src/pages/outposts/OutpostListPage.ts b/web/src/pages/outposts/OutpostListPage.ts index 1994e5d21..550a207c7 100644 --- a/web/src/pages/outposts/OutpostListPage.ts +++ b/web/src/pages/outposts/OutpostListPage.ts @@ -65,7 +65,16 @@ export class OutpostListPage extends TablePage { row(item: Outpost): TemplateResult[] { return [ - html`${item.name}`, + html`
+
${item.name}
+ ${item.config.authentik_host === "" + ? html` + ${t`Warning: authentik Domain is not configured, authentication will not work.`}` + : html` + ${t`Logging in via ${item.config.authentik_host}.`} `} +
`, html`
    ${item.providersObj?.map((p) => { return html`