admin: add API to show embedded outpost status, add notice when its not configured properly

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-10 19:16:11 +02:00
parent 0c9c3153b5
commit de9d483b9f
6 changed files with 66 additions and 1 deletions

View File

@ -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."""

View File

@ -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

View File

@ -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"

View File

@ -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 ""

View File

@ -16,6 +16,14 @@ export class SystemStatusCard extends AdminStatusCard<System> {
}
getStatus(value: System): Promise<AdminStatus> {
if (value.embeddedOutpostHost === "") {
this.header = t`Warning`;
return Promise.resolve<AdminStatus>({
icon: "fa fa-exclamation-triangle pf-m-warning",
message: html`${t`Embedded outpost is not configured correctly.`}
<a href="#/outpost/outposts">${t`Check outposts.`}</a>`,
});
}
if (!value.httpIsSecure && document.location.protocol === "https:") {
this.header = t`Warning`;
return Promise.resolve<AdminStatus>({

View File

@ -65,7 +65,16 @@ export class OutpostListPage extends TablePage<Outpost> {
row(item: Outpost): TemplateResult[] {
return [
html`${item.name}`,
html`<div>
<div>${item.name}</div>
${item.config.authentik_host === ""
? html`<i class="pf-icon pf-icon-warning-triangle"></i>
<small
>${t`Warning: authentik Domain is not configured, authentication will not work.`}</small
>`
: html`<i class="pf-icon pf-icon-ok"></i>
<small> ${t`Logging in via ${item.config.authentik_host}.`} </small>`}
</div>`,
html`<ul>
${item.providersObj?.map((p) => {
return html`<li>