import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import "@goauthentik/elements/forms/SearchSelect"; import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { CertificateKeyPair, CryptoApi, CryptoCertificatekeypairsListRequest, DockerServiceConnection, OutpostsApi, } from "@goauthentik/api"; @customElement("ak-service-connection-docker-form") export class ServiceConnectionDockerForm extends ModelForm { loadInstance(pk: string): Promise { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsDockerRetrieve({ uuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated integration.`; } else { return t`Successfully created integration.`; } } send = (data: DockerServiceConnection): Promise => { if (this.instance) { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsDockerUpdate({ uuid: this.instance.pk || "", dockerServiceConnectionRequest: data, }); } else { return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsDockerCreate({ dockerServiceConnectionRequest: data, }); } }; renderForm(): TemplateResult { return html`

${t`If enabled, use the local connection. Required Docker socket/Kubernetes Integration.`}

${t`Can be in the format of 'unix://' when connecting to a local docker daemon, using 'ssh://' to connect via SSH, or 'https://:2376' when connecting to a remote system.`}

=> { const args: CryptoCertificatekeypairsListRequest = { ordering: "name", hasKey: true, includeDetails: false, }; if (query !== undefined) { args.search = query; } const certificates = await new CryptoApi( DEFAULT_CONFIG, ).cryptoCertificatekeypairsList(args); return certificates.results; }} .renderElement=${(item: CertificateKeyPair): string => { return item.name; }} .value=${(item: CertificateKeyPair | undefined): string | undefined => { return item?.pk; }} .selected=${(item: CertificateKeyPair): boolean => { return this.instance?.tlsVerification === item.pk; }} ?blankable=${true} >

${t`CA which the endpoint's Certificate is verified against. Can be left empty for no validation.`}

=> { const args: CryptoCertificatekeypairsListRequest = { ordering: "name", hasKey: true, includeDetails: false, }; if (query !== undefined) { args.search = query; } const certificates = await new CryptoApi( DEFAULT_CONFIG, ).cryptoCertificatekeypairsList(args); return certificates.results; }} .renderElement=${(item: CertificateKeyPair): string => { return item.name; }} .value=${(item: CertificateKeyPair | undefined): string | undefined => { return item?.pk; }} .selected=${(item: CertificateKeyPair): boolean => { return this.instance?.tlsAuthentication === item.pk; }} ?blankable=${true} >

${t`Certificate/Key used for authentication. Can be left empty for no authentication.`}

${t`When connecting via SSH, this keypair is used for authentication.`}

`; } }