web: remove more until (#5057)
* more cleanup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't dynamically import duo form Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix import Signed-off-by: Jens Langhammer <jens@goauthentik.io> * properly send evens when tab isn't switched Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix loop on tabs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't bubble tab events Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove most other uses of until() Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup user settings Signed-off-by: Jens Langhammer <jens@goauthentik.io> * only use stale for issues Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -5,6 +5,7 @@ import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
||||
import { MessageLevel } from "@goauthentik/common/messages";
|
||||
import { AKElement } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/CodeMirror";
|
||||
import "@goauthentik/elements/EmptyState";
|
||||
import "@goauthentik/elements/Tabs";
|
||||
import "@goauthentik/elements/buttons/ActionButton";
|
||||
import "@goauthentik/elements/buttons/ModalButton";
|
||||
@ -15,9 +16,8 @@ import { showMessage } from "@goauthentik/elements/messages/MessageContainer";
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { CSSResult, TemplateResult, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators.js";
|
||||
import { customElement, property, state } from "lit/decorators.js";
|
||||
import { ifDefined } from "lit/directives/if-defined.js";
|
||||
import { until } from "lit/directives/until.js";
|
||||
|
||||
import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
|
||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||
@ -31,7 +31,13 @@ import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
||||
import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
|
||||
import { CryptoApi, ProvidersApi, SAMLProvider } from "@goauthentik/api";
|
||||
import {
|
||||
CertificateKeyPair,
|
||||
CryptoApi,
|
||||
ProvidersApi,
|
||||
SAMLMetadata,
|
||||
SAMLProvider,
|
||||
} from "@goauthentik/api";
|
||||
|
||||
interface SAMLPreviewAttribute {
|
||||
attributes: {
|
||||
@ -54,12 +60,40 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
.providersSamlRetrieve({
|
||||
id: value,
|
||||
})
|
||||
.then((prov) => (this.provider = prov));
|
||||
.then((prov) => {
|
||||
this.provider = prov;
|
||||
if (prov.signingKp) {
|
||||
new CryptoApi(DEFAULT_CONFIG)
|
||||
.cryptoCertificatekeypairsRetrieve({
|
||||
kpUuid: prov.signingKp,
|
||||
})
|
||||
.then((kp) => (this.signer = kp));
|
||||
}
|
||||
if (prov.verificationKp) {
|
||||
new CryptoApi(DEFAULT_CONFIG)
|
||||
.cryptoCertificatekeypairsRetrieve({
|
||||
kpUuid: prov.verificationKp,
|
||||
})
|
||||
.then((kp) => (this.verifier = kp));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@property({ attribute: false })
|
||||
provider?: SAMLProvider;
|
||||
|
||||
@state()
|
||||
preview?: SAMLPreviewAttribute;
|
||||
|
||||
@state()
|
||||
metadata?: SAMLMetadata;
|
||||
|
||||
@state()
|
||||
signer?: CertificateKeyPair;
|
||||
|
||||
@state()
|
||||
verifier?: CertificateKeyPair;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
PFBase,
|
||||
@ -84,7 +118,7 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
});
|
||||
}
|
||||
|
||||
async renderRelatedObjects(): Promise<TemplateResult> {
|
||||
renderRelatedObjects(): TemplateResult {
|
||||
const relatedObjects = [];
|
||||
if (this.provider?.assignedApplicationName) {
|
||||
relatedObjects.push(html`<div class="pf-c-description-list__group">
|
||||
@ -122,10 +156,7 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
</dd>
|
||||
</div>`);
|
||||
}
|
||||
if (this.provider?.signingKp) {
|
||||
const kp = await new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsRetrieve({
|
||||
kpUuid: this.provider.signingKp,
|
||||
});
|
||||
if (this.signer) {
|
||||
relatedObjects.push(html`<div class="pf-c-description-list__group">
|
||||
<dt class="pf-c-description-list__term">
|
||||
<span class="pf-c-description-list__text"
|
||||
@ -134,7 +165,9 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
<a class="pf-c-button pf-m-primary" href=${kp.certificateDownloadUrl}
|
||||
<a
|
||||
class="pf-c-button pf-m-primary"
|
||||
href=${this.signer.certificateDownloadUrl}
|
||||
>${t`Download`}</a
|
||||
>
|
||||
</div>
|
||||
@ -160,7 +193,19 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
${this.renderTabOverview()}
|
||||
</section>
|
||||
${this.renderTabMetadata()}
|
||||
<section slot="page-preview" data-tab-title="${t`Preview`}">
|
||||
<section
|
||||
slot="page-preview"
|
||||
data-tab-title="${t`Preview`}"
|
||||
@activate=${() => {
|
||||
new ProvidersApi(DEFAULT_CONFIG)
|
||||
.providersSamlPreviewUserRetrieve({
|
||||
id: this.provider?.pk || 0,
|
||||
})
|
||||
.then((preview) => {
|
||||
this.preview = preview.preview as SAMLPreviewAttribute;
|
||||
});
|
||||
}}
|
||||
>
|
||||
${this.renderTabPreview()}
|
||||
</section>
|
||||
<section
|
||||
@ -264,7 +309,7 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
</ak-forms-modal>
|
||||
</div>
|
||||
</div>
|
||||
${until(this.renderRelatedObjects())}
|
||||
${this.renderRelatedObjects()}
|
||||
${
|
||||
this.provider.assignedApplicationName
|
||||
? html` <div class="pf-c-card pf-l-grid__item pf-m-12-col">
|
||||
@ -364,7 +409,17 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
}
|
||||
return html`
|
||||
${this.provider.assignedApplicationName
|
||||
? html` <section slot="page-metadata" data-tab-title="${t`Metadata`}">
|
||||
? html` <section
|
||||
slot="page-metadata"
|
||||
data-tab-title="${t`Metadata`}"
|
||||
@activate=${() => {
|
||||
new ProvidersApi(DEFAULT_CONFIG)
|
||||
.providersSamlMetadataRetrieve({
|
||||
id: this.provider?.pk || 0,
|
||||
})
|
||||
.then((metadata) => (this.metadata = metadata));
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="pf-c-page__main-section pf-m-no-padding-mobile pf-l-grid pf-m-gutter"
|
||||
>
|
||||
@ -399,19 +454,11 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
</ak-action-button>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
${until(
|
||||
new ProvidersApi(DEFAULT_CONFIG)
|
||||
.providersSamlMetadataRetrieve({
|
||||
id: this.provider.pk || 0,
|
||||
})
|
||||
.then((m) => {
|
||||
return html`<ak-codemirror
|
||||
mode="xml"
|
||||
?readOnly=${true}
|
||||
value="${ifDefined(m.metadata)}"
|
||||
></ak-codemirror>`;
|
||||
}),
|
||||
)}
|
||||
<ak-codemirror
|
||||
mode="xml"
|
||||
?readOnly=${true}
|
||||
value="${ifDefined(this.metadata?.metadata)}"
|
||||
></ak-codemirror>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -421,65 +468,50 @@ export class SAMLProviderViewPage extends AKElement {
|
||||
}
|
||||
|
||||
renderTabPreview(): TemplateResult {
|
||||
if (!this.provider) {
|
||||
return html``;
|
||||
if (!this.preview) {
|
||||
return html`<ak-empty-state ?loading=${true}></ak-empty-state>`;
|
||||
}
|
||||
return html` <div
|
||||
class="pf-c-page__main-section pf-m-no-padding-mobile pf-l-grid pf-m-gutter"
|
||||
>
|
||||
<div class="pf-c-card">
|
||||
<div class="pf-c-card__title">${t`Example SAML attributes`}</div>
|
||||
${until(
|
||||
new ProvidersApi(DEFAULT_CONFIG)
|
||||
.providersSamlPreviewUserRetrieve({
|
||||
id: this.provider?.pk,
|
||||
})
|
||||
.then((data) => {
|
||||
const d = data.preview as SAMLPreviewAttribute;
|
||||
return html`
|
||||
<div class="pf-c-card__body">
|
||||
<dl class="pf-c-description-list pf-m-2-col-on-lg">
|
||||
<div class="pf-c-description-list__group">
|
||||
<dt class="pf-c-description-list__term">
|
||||
<span class="pf-c-description-list__text"
|
||||
>${t`NameID attribute`}</span
|
||||
>
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
${d.nameID}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div class="pf-c-card__body">
|
||||
<dl class="pf-c-description-list pf-m-2-col-on-lg">
|
||||
<div class="pf-c-description-list__group">
|
||||
<dt class="pf-c-description-list__term">
|
||||
<span class="pf-c-description-list__text"
|
||||
>${t`NameID attribute`}</span
|
||||
>
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
${this.preview?.nameID}
|
||||
</div>
|
||||
<div class="pf-c-card__body">
|
||||
<dl class="pf-c-description-list pf-m-2-col-on-lg">
|
||||
${d.attributes.map((attr) => {
|
||||
return html` <div class="pf-c-description-list__group">
|
||||
<dt class="pf-c-description-list__term">
|
||||
<span class="pf-c-description-list__text"
|
||||
>${attr.Name}</span
|
||||
>
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
<ul class="pf-c-list">
|
||||
${attr.Value.map((value) => {
|
||||
return html`
|
||||
<li><pre>${value}</pre></li>
|
||||
`;
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</dd>
|
||||
</div>`;
|
||||
})}
|
||||
</dl>
|
||||
</div>
|
||||
`;
|
||||
}),
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="pf-c-card__body">
|
||||
<dl class="pf-c-description-list pf-m-2-col-on-lg">
|
||||
${this.preview?.attributes.map((attr) => {
|
||||
return html` <div class="pf-c-description-list__group">
|
||||
<dt class="pf-c-description-list__term">
|
||||
<span class="pf-c-description-list__text">${attr.Name}</span>
|
||||
</dt>
|
||||
<dd class="pf-c-description-list__description">
|
||||
<div class="pf-c-description-list__text">
|
||||
<ul class="pf-c-list">
|
||||
${attr.Value.map((value) => {
|
||||
return html` <li><pre>${value}</pre></li> `;
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</dd>
|
||||
</div>`;
|
||||
})}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user