2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-03-29 14:23:43 +00:00
|
|
|
import { CSSResult, customElement, html, property, TemplateResult } from "lit-element";
|
2021-02-16 22:13:22 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
2021-03-29 14:23:43 +00:00
|
|
|
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
|
2021-02-16 22:13:22 +00:00
|
|
|
|
2021-03-16 20:32:39 +00:00
|
|
|
import { CryptoApi, CertificateKeyPair } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
|
2021-03-29 15:34:24 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
2021-02-16 22:13:22 +00:00
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-03-18 11:14:27 +00:00
|
|
|
import "../../elements/forms/DeleteForm";
|
2021-03-29 15:34:24 +00:00
|
|
|
import "./CertificateKeyPairForm";
|
|
|
|
import "./CertificateGenerateForm";
|
2021-02-16 22:13:22 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-02-16 22:13:22 +00:00
|
|
|
|
2021-03-28 14:10:00 +00:00
|
|
|
@customElement("ak-crypto-certificate-list")
|
2021-02-16 22:13:22 +00:00
|
|
|
export class CertificateKeyPairListPage extends TablePage<CertificateKeyPair> {
|
|
|
|
expandable = true;
|
|
|
|
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pageTitle(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`Certificate-Key Pairs`;
|
2021-02-16 22:13:22 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`Import certificates of external providers or create certificates to sign requests with.`;
|
2021-02-16 22:13:22 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
2021-03-20 15:06:56 +00:00
|
|
|
return "pf-icon pf-icon-key";
|
2021-02-16 22:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-03-29 14:23:43 +00:00
|
|
|
static get styles(): CSSResult[] {
|
|
|
|
return super.styles.concat(PFDescriptionList);
|
|
|
|
}
|
|
|
|
|
2021-02-16 22:13:22 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<CertificateKeyPair>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsList({
|
2021-02-16 22:13:22 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-08 10:14:00 +00:00
|
|
|
pageSize: PAGE_SIZE,
|
2021-02-16 22:13:22 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
2021-04-04 14:56:16 +00:00
|
|
|
new TableColumn(t`Name`, "name"),
|
2021-04-04 14:22:29 +00:00
|
|
|
new TableColumn(t`Private key available?`),
|
|
|
|
new TableColumn(t`Expiry date`),
|
2021-02-16 22:13:22 +00:00
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
row(item: CertificateKeyPair): TemplateResult[] {
|
|
|
|
return [
|
|
|
|
html`${item.name}`,
|
2021-04-03 17:26:43 +00:00
|
|
|
html`${item.privateKeyAvailable ? t`Yes` : t`No`}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.certExpiry?.toLocaleString()}`,
|
2021-02-16 22:13:22 +00:00
|
|
|
html`
|
2021-03-29 15:34:24 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Update Certificate-Key Pair`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
2021-05-11 09:55:25 +00:00
|
|
|
<ak-crypto-certificate-form slot="form" .instancePk=${item.pk}>
|
2021-03-29 15:34:24 +00:00
|
|
|
</ak-crypto-certificate-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Edit`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-03-18 11:14:27 +00:00
|
|
|
<ak-forms-delete
|
|
|
|
.obj=${item}
|
2021-04-03 17:26:43 +00:00
|
|
|
objectLabel=${t`Certificate-Key Pair`}
|
2021-03-18 11:14:27 +00:00
|
|
|
.delete=${() => {
|
|
|
|
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsDelete({
|
|
|
|
kpUuid: item.pk || ""
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-danger">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Delete`}
|
2021-03-18 11:14:27 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-delete>`,
|
2021-02-16 22:13:22 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderExpanded(item: CertificateKeyPair): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<td role="cell" colspan="3">
|
|
|
|
<div class="pf-c-table__expandable-row-content">
|
2021-03-08 10:14:00 +00:00
|
|
|
<dl class="pf-c-description-list pf-m-horizontal">
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Certificate Fingerprint`}</span>
|
2021-03-08 10:14:00 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">${item.fingerprint}</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
2021-04-03 17:26:43 +00:00
|
|
|
<span class="pf-c-description-list__text">${t`Certificate Subjet`}</span>
|
2021-03-08 10:14:00 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">${item.certSubject}</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
</dl>
|
2021-02-16 22:13:22 +00:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
|
|
|
return html`
|
2021-03-29 15:34:24 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create Certificate-Key Pair`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
|
|
|
<ak-crypto-certificate-form slot="form">
|
|
|
|
</ak-crypto-certificate-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-primary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Create`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Generate`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
|
|
|
<span slot="header">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Generate Certificate-Key Pair`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</span>
|
|
|
|
<ak-crypto-certificate-generate-form slot="form">
|
|
|
|
</ak-crypto-certificate-generate-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
2021-04-03 17:26:43 +00:00
|
|
|
${t`Generate`}
|
2021-03-29 15:34:24 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-02-16 22:13:22 +00:00
|
|
|
${super.renderToolbar()}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|