2021-02-04 08:54:00 +00:00
|
|
|
import { gettext } from "django";
|
|
|
|
import { customElement, html, property, TemplateResult } from "lit-element";
|
2021-02-09 16:04:55 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
2021-02-04 08:54:00 +00:00
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-02-04 09:22:14 +00:00
|
|
|
import "../../elements/buttons/Dropdown";
|
2021-03-18 11:14:27 +00:00
|
|
|
import "../../elements/forms/DeleteForm";
|
2021-04-01 13:39:59 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
|
|
|
import "../../elements/forms/ProxyForm";
|
|
|
|
import "./oauth2/OAuth2ProviderForm";
|
|
|
|
import "./proxy/ProxyProviderForm";
|
|
|
|
import "./saml/SAMLProviderForm";
|
2021-04-01 17:28:12 +00:00
|
|
|
import "./saml/SAMLProviderImportForm";
|
2021-02-04 08:54:00 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
2021-02-10 19:11:54 +00:00
|
|
|
import { until } from "lit-html/directives/until";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-03-16 20:32:39 +00:00
|
|
|
import { Provider, ProvidersApi } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-04-01 13:39:59 +00:00
|
|
|
import { ifDefined } from "lit-html/directives/if-defined";
|
2021-02-04 08:54:00 +00:00
|
|
|
|
|
|
|
@customElement("ak-provider-list")
|
|
|
|
export class ProviderListPage extends TablePage<Provider> {
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pageTitle(): string {
|
|
|
|
return gettext("Provider");
|
|
|
|
}
|
|
|
|
pageDescription(): string {
|
|
|
|
return gettext("Provide support for protocols like SAML and OAuth to assigned applications.");
|
|
|
|
}
|
|
|
|
pageIcon(): string {
|
2021-03-20 15:06:56 +00:00
|
|
|
return "pf-icon pf-icon-integration";
|
2021-02-04 08:54:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-02-09 16:04:55 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<Provider>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new ProvidersApi(DEFAULT_CONFIG).providersAllList({
|
2021-02-04 08:54:00 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-08 10:14:00 +00:00
|
|
|
pageSize: PAGE_SIZE,
|
2021-02-04 08:54:00 +00:00
|
|
|
search: this.search || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
|
|
|
new TableColumn("Name", "name"),
|
|
|
|
new TableColumn("Application"),
|
|
|
|
new TableColumn("Type", "type"),
|
|
|
|
new TableColumn(""),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
row(item: Provider): TemplateResult[] {
|
|
|
|
return [
|
2021-02-19 18:29:17 +00:00
|
|
|
html`<a href="#/core/providers/${item.pk}">
|
2021-02-04 08:54:00 +00:00
|
|
|
${item.name}
|
|
|
|
</a>`,
|
2021-03-08 10:14:00 +00:00
|
|
|
item.assignedApplicationName ?
|
2021-02-04 08:54:00 +00:00
|
|
|
html`<i class="pf-icon pf-icon-ok"></i>
|
|
|
|
${gettext("Assigned to application ")}
|
2021-03-08 10:14:00 +00:00
|
|
|
<a href="#/core/applications/${item.assignedApplicationSlug}">${item.assignedApplicationName}</a>` :
|
2021-02-04 08:54:00 +00:00
|
|
|
html`<i class="pf-icon pf-icon-warning-triangle"></i>
|
|
|
|
${gettext("Warning: Provider not assigned to any application.")}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.verboseName}`,
|
2021-02-04 08:54:00 +00:00
|
|
|
html`
|
2021-04-01 13:39:59 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
|
|
|
${gettext("Update")}
|
|
|
|
</span>
|
|
|
|
<span slot="header">
|
|
|
|
${gettext(`Update ${item.verboseName}`)}
|
|
|
|
</span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
|
|
|
.args=${{
|
|
|
|
"providerUUID": item.pk
|
|
|
|
}}
|
|
|
|
type=${ifDefined(item.objectType)}
|
|
|
|
.typeMap=${{
|
|
|
|
"oauth2": "ak-provider-oauth2-form",
|
|
|
|
"saml": "ak-provider-saml-form",
|
|
|
|
"proxy": "ak-provider-proxy-form",
|
|
|
|
}}>
|
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
2021-02-04 09:22:14 +00:00
|
|
|
${gettext("Edit")}
|
2021-04-01 13:39:59 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-03-18 11:14:27 +00:00
|
|
|
<ak-forms-delete
|
|
|
|
.obj=${item}
|
|
|
|
objectLabel=${gettext("Source")}
|
|
|
|
.delete=${() => {
|
|
|
|
return new ProvidersApi(DEFAULT_CONFIG).providersAllDelete({
|
|
|
|
id: item.pk || 0
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-danger">
|
2021-02-04 09:22:14 +00:00
|
|
|
${gettext("Delete")}
|
2021-03-18 11:14:27 +00:00
|
|
|
</button>
|
|
|
|
</ak-forms-delete>`,
|
2021-02-04 08:54:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<ak-dropdown class="pf-c-dropdown">
|
|
|
|
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
|
|
|
|
<span class="pf-c-dropdown__toggle-text">${gettext("Create")}</span>
|
|
|
|
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
<ul class="pf-c-dropdown__menu" hidden>
|
2021-04-02 11:27:18 +00:00
|
|
|
${until(new ProvidersApi(DEFAULT_CONFIG).providersAllTypes().then((types) => {
|
2021-02-10 19:11:54 +00:00
|
|
|
return types.map((type) => {
|
|
|
|
return html`<li>
|
2021-04-01 13:39:59 +00:00
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit">
|
|
|
|
${gettext("Create")}
|
|
|
|
</span>
|
|
|
|
<span slot="header">
|
|
|
|
${gettext(`Create ${type.name}`)}
|
|
|
|
</span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
2021-04-02 21:12:17 +00:00
|
|
|
type=${type.component}>
|
2021-04-01 13:39:59 +00:00
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
|
|
|
${type.name}<br>
|
2021-02-10 19:11:54 +00:00
|
|
|
<small>${type.description}</small>
|
|
|
|
</button>
|
2021-04-01 13:39:59 +00:00
|
|
|
</ak-forms-modal>
|
2021-02-10 19:11:54 +00:00
|
|
|
</li>`;
|
2021-02-10 19:12:15 +00:00
|
|
|
});
|
2021-02-10 19:11:54 +00:00
|
|
|
}), html`<ak-spinner></ak-spinner>`)}
|
2021-02-04 08:54:00 +00:00
|
|
|
</ul>
|
|
|
|
</ak-dropdown>
|
|
|
|
${super.renderToolbar()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|