From 0478ae3da86cc00ac04bcb574b82c8e3cba63e40 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 1 Mar 2021 10:49:00 +0100 Subject: [PATCH] web: add missing SAML Source display page --- web/src/api/sources/SAML.ts | 32 +++++ web/src/pages/sources/OAuthSourceViewPage.ts | 5 - web/src/pages/sources/SAMLSourceViewPage.ts | 125 +++++++++++++++++++ web/src/pages/sources/SourceViewPage.ts | 3 + 4 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 web/src/api/sources/SAML.ts create mode 100644 web/src/pages/sources/SAMLSourceViewPage.ts diff --git a/web/src/api/sources/SAML.ts b/web/src/api/sources/SAML.ts new file mode 100644 index 000000000..949f37b3c --- /dev/null +++ b/web/src/api/sources/SAML.ts @@ -0,0 +1,32 @@ +import { DefaultClient } from "../Client"; +import { Source } from "../Sources"; + +export class SAMLSource extends Source { + issuer: string; + sso_url: string; + slo_url: string; + allow_idp_initiated: boolean; + name_id_policy: string; + binding_type: string + signing_kp?: string; + digest_algorithm: string; + signature_algorithm: string; + temporary_user_delete_after: string; + + constructor() { + super(); + throw Error(); + } + + static get(slug: string): Promise { + return DefaultClient.fetch(["sources", "saml", slug]); + } + + static getMetadata(slug: string): Promise<{ metadata: string }> { + return DefaultClient.fetch(["sources", "saml", slug, "metadata"]); + } + + static appUrl(slug: string, rest: string): string { + return `/source/saml/${slug}/${rest}`; + } +} diff --git a/web/src/pages/sources/OAuthSourceViewPage.ts b/web/src/pages/sources/OAuthSourceViewPage.ts index b60ef4a89..0c327f24d 100644 --- a/web/src/pages/sources/OAuthSourceViewPage.ts +++ b/web/src/pages/sources/OAuthSourceViewPage.ts @@ -22,11 +22,6 @@ export class OAuthSourceViewPage extends Page { return "pf-icon pf-icon-middleware"; } - @property() - set args(value: { [key: string]: string }) { - this.sourceSlug = value.slug; - } - @property({ type: String }) set sourceSlug(value: string) { OAuthSource.get(value).then((s) => this.source = s); diff --git a/web/src/pages/sources/SAMLSourceViewPage.ts b/web/src/pages/sources/SAMLSourceViewPage.ts new file mode 100644 index 000000000..755c4fd82 --- /dev/null +++ b/web/src/pages/sources/SAMLSourceViewPage.ts @@ -0,0 +1,125 @@ +import { gettext } from "django"; +import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; +import { until } from "lit-html/directives/until"; +import { Source } from "../../api/Sources"; +import { SAMLSource } from "../../api/sources/SAML"; +import { COMMON_STYLES } from "../../common/styles"; + +import "../../elements/buttons/ModalButton"; +import "../../elements/buttons/SpinnerButton"; +import "../../elements/CodeMirror"; +import "../../elements/Tabs"; +import { Page } from "../../elements/Page"; + +@customElement("ak-source-saml-view") +export class SAMLSourceViewPage extends Page { + pageTitle(): string { + return gettext(`SAML Source ${this.source?.name || ""}`); + } + pageDescription(): string | undefined { + return; + } + pageIcon(): string { + return "pf-icon pf-icon-integration"; + } + + @property({ type: String }) + set sourceSlug(slug: string) { + SAMLSource.get(slug).then((s) => this.source = s); + } + + @property({ attribute: false }) + source?: SAMLSource; + + static get styles(): CSSResult[] { + return COMMON_STYLES; + } + + constructor() { + super(); + this.addEventListener("ak-refresh", () => { + if (!this.source?.pk) return; + this.sourceSlug = this.source?.slug; + }); + } + + renderContent(): TemplateResult { + if (!this.source) { + return html``; + } + return html` +
+
+
+
+
+
+
+
+ ${gettext("Name")} +
+
+
${this.source.name}
+
+
+
+
+ ${gettext("SSO URL")} +
+
+
${this.source.sso_url}
+
+
+
+
+ ${gettext("SLO URL")} +
+
+
${this.source.slo_url}
+
+
+
+
+ ${gettext("Issuer")} +
+
+
${this.source.issuer}
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ ${until( + SAMLSource.getMetadata(this.source.slug).then(m => { + return html``; + }) + )} +
+ +
+
+
+
+
`; + } +} diff --git a/web/src/pages/sources/SourceViewPage.ts b/web/src/pages/sources/SourceViewPage.ts index 81d8a07ff..3d3edf1fd 100644 --- a/web/src/pages/sources/SourceViewPage.ts +++ b/web/src/pages/sources/SourceViewPage.ts @@ -7,6 +7,7 @@ import { SpinnerSize } from "../../elements/Spinner"; import "./LDAPSourceViewPage"; import "./OAuthSourceViewPage"; +import "./SAMLSourceViewPage"; import { Source } from "../../api/Sources"; @customElement("ak-source-view") @@ -49,6 +50,8 @@ export class SourceViewPage extends LitElement { return html``; case "oauth": return html``; + case "saml": + return html``; default: return html`

Invalid source type ${this.source.object_type}

`; }