2021-08-15 19:32:28 +00:00
|
|
|
import { CertificateGenerationRequest, CertificateKeyPair, CryptoApi } from "@goauthentik/api";
|
2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:19:26 +00:00
|
|
|
import { customElement } from "lit/decorators";
|
|
|
|
import { html, TemplateResult } from "lit";
|
2021-03-29 15:34:24 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { Form } from "../../elements/forms/Form";
|
|
|
|
import "../../elements/forms/HorizontalFormElement";
|
|
|
|
|
|
|
|
@customElement("ak-crypto-certificate-generate-form")
|
2021-05-16 16:24:15 +00:00
|
|
|
export class CertificateKeyPairForm extends Form<CertificateGenerationRequest> {
|
2021-03-29 15:34:24 +00:00
|
|
|
getSuccessMessage(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`Successfully generated certificate-key pair.`;
|
2021-03-29 15:34:24 +00:00
|
|
|
}
|
|
|
|
|
2021-05-16 16:24:15 +00:00
|
|
|
send = (data: CertificateGenerationRequest): Promise<CertificateKeyPair> => {
|
|
|
|
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsGenerateCreate({
|
2021-08-03 15:52:21 +00:00
|
|
|
certificateGenerationRequest: data,
|
2021-03-29 15:34:24 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
renderForm(): TemplateResult {
|
|
|
|
return html`<form class="pf-c-form pf-m-horizontal">
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-form-element-horizontal label=${t`Common Name`} name="commonName" ?required=${true}>
|
|
|
|
<input type="text" class="pf-c-form-control" required />
|
2021-03-29 15:34:24 +00:00
|
|
|
</ak-form-element-horizontal>
|
2021-08-03 15:52:21 +00:00
|
|
|
<ak-form-element-horizontal label=${t`Subject-alt name`} name="subjectAltName">
|
|
|
|
<input class="pf-c-form-control" type="text" />
|
|
|
|
<p class="pf-c-form__helper-text">
|
|
|
|
${t`Optional, comma-separated SubjectAlt Names.`}
|
|
|
|
</p>
|
2021-03-29 15:34:24 +00:00
|
|
|
</ak-form-element-horizontal>
|
2021-03-29 16:22:15 +00:00
|
|
|
<ak-form-element-horizontal
|
2021-04-03 17:26:43 +00:00
|
|
|
label=${t`Validity days`}
|
2021-03-29 16:22:15 +00:00
|
|
|
name="validityDays"
|
2021-08-03 15:52:21 +00:00
|
|
|
?required=${true}
|
|
|
|
>
|
|
|
|
<input class="pf-c-form-control" type="number" value="365" />
|
2021-03-29 15:34:24 +00:00
|
|
|
</ak-form-element-horizontal>
|
|
|
|
</form>`;
|
|
|
|
}
|
|
|
|
}
|