2021-02-09 15:17:59 +00:00
|
|
|
import { gettext } from "django";
|
|
|
|
import { CSSResult, customElement, html, property, TemplateResult } from "lit-element";
|
2021-03-17 16:11:39 +00:00
|
|
|
|
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
|
|
import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
2021-02-09 15:17:59 +00:00
|
|
|
|
|
|
|
import "../../elements/buttons/ModalButton";
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
|
|
|
import "../../elements/CodeMirror";
|
|
|
|
import "../../elements/Tabs";
|
|
|
|
import { Page } from "../../elements/Page";
|
2021-03-16 20:32:39 +00:00
|
|
|
import { OAuthSource, SourcesApi } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
|
|
import { AdminURLManager } from "../../api/legacy";
|
2021-02-09 15:17:59 +00:00
|
|
|
|
|
|
|
@customElement("ak-source-oauth-view")
|
|
|
|
export class OAuthSourceViewPage extends Page {
|
|
|
|
pageTitle(): string {
|
2021-02-09 15:47:49 +00:00
|
|
|
return gettext(`OAuth Source ${this.source?.name || ""}`);
|
2021-02-09 15:17:59 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string | undefined {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pageIcon(): string {
|
|
|
|
return "pf-icon pf-icon-middleware";
|
|
|
|
}
|
|
|
|
|
|
|
|
@property({ type: String })
|
2021-02-09 15:47:49 +00:00
|
|
|
set sourceSlug(value: string) {
|
2021-03-08 10:14:00 +00:00
|
|
|
new SourcesApi(DEFAULT_CONFIG).sourcesOauthRead({
|
|
|
|
slug: value
|
|
|
|
}).then((source) => {
|
|
|
|
this.source = source;
|
|
|
|
});
|
2021-02-09 15:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@property({ attribute: false })
|
2021-02-09 15:47:49 +00:00
|
|
|
source?: OAuthSource;
|
2021-02-09 15:17:59 +00:00
|
|
|
|
|
|
|
static get styles(): CSSResult[] {
|
2021-03-17 16:11:39 +00:00
|
|
|
return [PFPage, PFGallery, PFContent];
|
2021-02-09 15:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.addEventListener("ak-refresh", () => {
|
|
|
|
if (!this.source?.pk) return;
|
2021-02-09 15:47:49 +00:00
|
|
|
this.sourceSlug = this.source?.slug;
|
2021-02-09 15:17:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderContent(): TemplateResult {
|
|
|
|
if (!this.source) {
|
|
|
|
return html``;
|
|
|
|
}
|
|
|
|
return html`<ak-tabs>
|
|
|
|
<section slot="page-1" data-tab-title="${gettext("Overview")}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
|
|
|
<div class="pf-u-display-flex pf-u-justify-content-center">
|
|
|
|
<div class="pf-u-w-75">
|
|
|
|
<div class="pf-c-card pf-c-card-aggregate">
|
|
|
|
<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">${gettext("Name")}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">${this.source.name}</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
2021-02-09 15:47:49 +00:00
|
|
|
<span class="pf-c-description-list__text">${gettext("Provider Type")}</span>
|
2021-02-09 15:17:59 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
2021-03-08 10:14:00 +00:00
|
|
|
<div class="pf-c-description-list__text">${this.source.providerType}</div>
|
2021-02-09 15:17:59 +00:00
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
2021-02-09 15:47:49 +00:00
|
|
|
<span class="pf-c-description-list__text">${gettext("Callback URL")}</span>
|
2021-02-09 15:17:59 +00:00
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
2021-03-08 10:14:00 +00:00
|
|
|
<code class="pf-c-description-list__text">${this.source.callbackUrl}</code>
|
2021-02-09 15:47:49 +00:00
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text">${gettext("Access Key")}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
2021-03-08 10:14:00 +00:00
|
|
|
<div class="pf-c-description-list__text">${this.source.consumerKey}</div>
|
2021-02-09 15:47:49 +00:00
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text">${gettext("Authorization URL")}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
2021-03-08 10:14:00 +00:00
|
|
|
<div class="pf-c-description-list__text">${this.source.authorizationUrl}</div>
|
2021-02-09 15:47:49 +00:00
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text">${gettext("Token URL")}</span>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
2021-03-08 10:14:00 +00:00
|
|
|
<div class="pf-c-description-list__text">${this.source.accessTokenUrl}</div>
|
2021-02-09 15:17:59 +00:00
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
2021-03-08 10:14:00 +00:00
|
|
|
<ak-modal-button href="${AdminURLManager.sources(`${this.source.pk}/update/`)}">
|
2021-02-09 15:17:59 +00:00
|
|
|
<ak-spinner-button slot="trigger" class="pf-m-primary">
|
|
|
|
${gettext("Edit")}
|
|
|
|
</ak-spinner-button>
|
|
|
|
<div slot="modal"></div>
|
|
|
|
</ak-modal-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</ak-tabs>`;
|
|
|
|
}
|
|
|
|
}
|