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:
		| @ -16,6 +16,8 @@ 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.outposts.managed import MANAGED_OUTPOST | ||||||
|  | from authentik.outposts.models import Outpost | ||||||
|  |  | ||||||
|  |  | ||||||
| class RuntimeDict(TypedDict): | class RuntimeDict(TypedDict): | ||||||
| @ -38,6 +40,7 @@ class SystemSerializer(PassiveSerializer): | |||||||
|     runtime = SerializerMethodField() |     runtime = SerializerMethodField() | ||||||
|     tenant = SerializerMethodField() |     tenant = SerializerMethodField() | ||||||
|     server_time = SerializerMethodField() |     server_time = SerializerMethodField() | ||||||
|  |     embedded_outpost_host = SerializerMethodField() | ||||||
|  |  | ||||||
|     def get_http_headers(self, request: Request) -> dict[str, str]: |     def get_http_headers(self, request: Request) -> dict[str, str]: | ||||||
|         """Get HTTP Request headers""" |         """Get HTTP Request headers""" | ||||||
| @ -75,6 +78,13 @@ class SystemSerializer(PassiveSerializer): | |||||||
|         """Current server time""" |         """Current server time""" | ||||||
|         return now() |         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): | class SystemView(APIView): | ||||||
|     """Get system information.""" |     """Get system information.""" | ||||||
|  | |||||||
| @ -29524,7 +29524,11 @@ components: | |||||||
|           type: string |           type: string | ||||||
|           format: date-time |           format: date-time | ||||||
|           readOnly: true |           readOnly: true | ||||||
|  |         embedded_outpost_host: | ||||||
|  |           type: string | ||||||
|  |           readOnly: true | ||||||
|       required: |       required: | ||||||
|  |       - embedded_outpost_host | ||||||
|       - http_headers |       - http_headers | ||||||
|       - http_host |       - http_host | ||||||
|       - http_is_secure |       - http_is_secure | ||||||
|  | |||||||
| @ -611,6 +611,10 @@ msgstr "Check Username" | |||||||
| msgid "Check access" | msgid "Check access" | ||||||
| msgstr "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 | #: src/flows/stages/authenticator_duo/AuthenticatorDuoStage.ts | ||||||
| msgid "Check status" | msgid "Check status" | ||||||
| msgstr "Check status" | msgstr "Check status" | ||||||
| @ -1365,6 +1369,10 @@ msgstr "Email stage" | |||||||
| msgid "Email: Text field with Email type." | msgid "Email: Text field with Email type." | ||||||
| msgstr "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" | #~ msgid "Enable" | ||||||
| @ -2252,6 +2260,10 @@ msgstr "Local" | |||||||
| msgid "Log the currently pending user in." | msgid "Log the currently pending user in." | ||||||
| msgstr "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 | #: src/pages/events/utils.ts | ||||||
| msgid "Login" | msgid "Login" | ||||||
| msgstr "Login" | msgstr "Login" | ||||||
| @ -4744,6 +4756,7 @@ msgstr "Wait (max)" | |||||||
| msgid "Wait (min)" | msgid "Wait (min)" | ||||||
| msgstr "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/admin-overview/cards/SystemStatusCard.ts | #: src/pages/admin-overview/cards/SystemStatusCard.ts | ||||||
| #: src/pages/events/RuleForm.ts | #: src/pages/events/RuleForm.ts | ||||||
| @ -4759,6 +4772,10 @@ msgstr "Warning: Policy is not assigned." | |||||||
| msgid "Warning: Provider not assigned to any application." | msgid "Warning: Provider not assigned to any application." | ||||||
| msgstr "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 | #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts | ||||||
| msgid "WebAuthn Authenticators" | msgid "WebAuthn Authenticators" | ||||||
| msgstr "WebAuthn Authenticators" | msgstr "WebAuthn Authenticators" | ||||||
|  | |||||||
| @ -607,6 +607,10 @@ msgstr "" | |||||||
| msgid "Check access" | msgid "Check access" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: src/pages/admin-overview/cards/SystemStatusCard.ts | ||||||
|  | msgid "Check outposts." | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
| #: src/flows/stages/authenticator_duo/AuthenticatorDuoStage.ts | #: src/flows/stages/authenticator_duo/AuthenticatorDuoStage.ts | ||||||
| msgid "Check status" | msgid "Check status" | ||||||
| msgstr "" | msgstr "" | ||||||
| @ -1357,6 +1361,10 @@ msgstr "" | |||||||
| msgid "Email: Text field with Email type." | msgid "Email: Text field with Email type." | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: src/pages/admin-overview/cards/SystemStatusCard.ts | ||||||
|  | msgid "Embedded outpost is not configured correctly." | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
| #:  | #:  | ||||||
| #:  | #:  | ||||||
| #~ msgid "Enable" | #~ msgid "Enable" | ||||||
| @ -2244,6 +2252,10 @@ msgstr "" | |||||||
| msgid "Log the currently pending user in." | msgid "Log the currently pending user in." | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: src/pages/outposts/OutpostListPage.ts | ||||||
|  | msgid "Logging in via {0}." | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
| #: src/pages/events/utils.ts | #: src/pages/events/utils.ts | ||||||
| msgid "Login" | msgid "Login" | ||||||
| msgstr "" | msgstr "" | ||||||
| @ -4729,6 +4741,7 @@ msgstr "" | |||||||
| msgid "Wait (min)" | msgid "Wait (min)" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|  | #: src/pages/admin-overview/cards/SystemStatusCard.ts | ||||||
| #: src/pages/admin-overview/cards/SystemStatusCard.ts | #: 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 | #: src/pages/events/RuleForm.ts | ||||||
| @ -4744,6 +4757,10 @@ msgstr "" | |||||||
| msgid "Warning: Provider not assigned to any application." | msgid "Warning: Provider not assigned to any application." | ||||||
| msgstr "" | 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 | #: src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts | ||||||
| msgid "WebAuthn Authenticators" | msgid "WebAuthn Authenticators" | ||||||
| msgstr "" | msgstr "" | ||||||
|  | |||||||
| @ -16,6 +16,14 @@ export class SystemStatusCard extends AdminStatusCard<System> { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     getStatus(value: System): Promise<AdminStatus> { |     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:") { |         if (!value.httpIsSecure && document.location.protocol === "https:") { | ||||||
|             this.header = t`Warning`; |             this.header = t`Warning`; | ||||||
|             return Promise.resolve<AdminStatus>({ |             return Promise.resolve<AdminStatus>({ | ||||||
|  | |||||||
| @ -65,7 +65,16 @@ export class OutpostListPage extends TablePage<Outpost> { | |||||||
|  |  | ||||||
|     row(item: Outpost): TemplateResult[] { |     row(item: Outpost): TemplateResult[] { | ||||||
|         return [ |         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> |             html`<ul> | ||||||
|                 ${item.providersObj?.map((p) => { |                 ${item.providersObj?.map((p) => { | ||||||
|                     return html`<li> |                     return html`<li> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer