import { CertificateKeyPair, CoreApi, CryptoApi, Group } from "authentik-api"; import { gettext } from "django"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { Form } from "../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import "../../elements/CodeMirror"; import "../../elements/Divider"; @customElement("ak-crypto-certificate-form") export class CertificateKeyPairForm extends Form { @property({attribute: false}) keyPair?: CertificateKeyPair; getSuccessMessage(): string { if (this.keyPair) { return gettext("Successfully updated certificate-key pair."); } else { return gettext("Successfully created certificate-key pair."); } } send = (data: CertificateKeyPair): Promise => { if (this.keyPair) { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsPartialUpdate({ kpUuid: this.keyPair.pk || "", data: data }); } else { return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsCreate({ data: data }); } }; renderForm(): TemplateResult { return html`
${this.keyPair ? html`${gettext("Only change the fields below if you want to overwrite their values.")}` : html``}

${gettext("PEM-encoded Certificate data.")}

${gettext("Optional Private Key. If this is set, you can use this keypair for encryption.")}

`; } }