import "@goauthentik/admin/outposts/OutpostDeploymentModal"; import "@goauthentik/admin/outposts/OutpostDeploymentModal"; import "@goauthentik/admin/outposts/OutpostForm"; import "@goauthentik/admin/outposts/OutpostHealth"; import "@goauthentik/admin/outposts/OutpostHealthSimple"; import "@goauthentik/admin/rbac/ObjectPermissionModal"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { PFSize } from "@goauthentik/common/enums.js"; import { PFColor } from "@goauthentik/elements/Label"; import "@goauthentik/elements/buttons/SpinnerButton"; import "@goauthentik/elements/forms/DeleteBulkForm"; import "@goauthentik/elements/forms/ModalForm"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { TableColumn } from "@goauthentik/elements/table/Table"; import { TablePage } from "@goauthentik/elements/table/TablePage"; import "@patternfly/elements/pf-tooltip/pf-tooltip.js"; import { msg, str } from "@lit/localize"; import { CSSResult } from "lit"; import { TemplateResult, html } from "lit"; import { customElement, property, state } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import { Outpost, OutpostHealth, OutpostTypeEnum, OutpostsApi, RbacPermissionsAssignedByUsersListModelEnum, } from "@goauthentik/api"; export function TypeToLabel(type?: OutpostTypeEnum): string { if (!type) return ""; switch (type) { case OutpostTypeEnum.Proxy: return msg("Proxy"); case OutpostTypeEnum.Ldap: return msg("LDAP"); case OutpostTypeEnum.Radius: return msg("Radius"); case OutpostTypeEnum.Rac: return msg("RAC"); case OutpostTypeEnum.UnknownDefaultOpenApi: return msg("Unknown type"); } } @customElement("ak-outpost-list") export class OutpostListPage extends TablePage { expandable = true; pageTitle(): string { return msg("Outposts"); } pageDescription(): string | undefined { return msg( "Outposts are deployments of authentik components to support different environments and protocols, like reverse proxies.", ); } pageIcon(): string { return "pf-icon pf-icon-zone"; } searchEnabled(): boolean { return true; } async apiEndpoint(): Promise> { const outposts = await new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesList( await this.defaultEndpointConfig(), ); Promise.all( outposts.results.map((outpost) => { return new OutpostsApi(DEFAULT_CONFIG) .outpostsInstancesHealthList({ uuid: outpost.pk, }) .then((health) => { this.health[outpost.pk] = health; }); }), ); return outposts; } @state() health: { [key: string]: OutpostHealth[] } = {}; columns(): TableColumn[] { return [ new TableColumn(msg("Name"), "name"), new TableColumn(msg("Type"), "type"), new TableColumn(msg("Providers")), new TableColumn(msg("Integration"), "service_connection__name"), new TableColumn(msg("Health and Version")), new TableColumn(msg("Actions")), ]; } static get styles(): CSSResult[] { return super.styles.concat(PFDescriptionList); } checkbox = true; clearOnRefresh = true; @property() order = "name"; row(item: Outpost): TemplateResult[] { return [ html`
${item.name}
${item.config.authentik_host === "" ? html` ${msg( "Warning: authentik Domain is not configured, authentication will not work.", )} ` : html` ${msg(str`Logging in via ${item.config.authentik_host}.`)} `}`, html`${TypeToLabel(item.type)}`, html``, html`${item.serviceConnectionObj?.name || msg("No integration active")}`, html``, html` ${msg("Update")} ${msg("Update Outpost")} ${item.managed !== "goauthentik.io/outposts/embedded" ? html` ` : html``}`, ]; } renderExpanded(item: Outpost): TemplateResult { return html`

${msg( "Detailed health (one instance per column, data is cached so may be out of date)", )}

${this.health[item.pk].map((h) => { return html`
`; })}
`; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUsedByList({ uuid: item.pk, }); }} .delete=${(item: Outpost) => { return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDestroy({ uuid: item.pk, }); }} > `; } renderObjectCreate(): TemplateResult { return html` ${msg("Create")} ${msg("Create Outpost")} `; } }