2021-05-24 20:21:18 +00:00
|
|
|
import { CertificateGenerationRequest, CertificateKeyPair, CryptoApi } from "authentik-api";
|
2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-03-29 16:22:15 +00:00
|
|
|
import { customElement } from "lit-element";
|
2021-03-29 15:34:24 +00:00
|
|
|
import { html, TemplateResult } from "lit-html";
|
|
|
|
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({
|
|
|
|
certificateGenerationRequest: data
|
2021-03-29 15:34:24 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
renderForm(): TemplateResult {
|
|
|
|
return html`<form class="pf-c-form pf-m-horizontal">
|
2021-03-29 16:22:15 +00:00
|
|
|
<ak-form-element-horizontal
|
2021-04-03 17:26:43 +00:00
|
|
|
label=${t`Common Name`}
|
2021-03-29 16:22:15 +00:00
|
|
|
name="commonName"
|
|
|
|
?required=${true}>
|
2021-03-29 16:25:59 +00:00
|
|
|
<input type="text" class="pf-c-form-control" required>
|
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`Subject-alt name`}
|
2021-03-29 16:22:15 +00:00
|
|
|
name="subjectAltName">
|
|
|
|
<input class="pf-c-form-control" type="text">
|
2021-04-03 17:26:43 +00:00
|
|
|
<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"
|
|
|
|
?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>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|