2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-09-21 09:31:37 +00:00
|
|
|
|
2021-10-28 07:48:51 +00:00
|
|
|
import { CSSResult, LitElement, TemplateResult, html } from "lit";
|
2021-11-04 21:34:48 +00:00
|
|
|
import { customElement, property } from "lit/decorators.js";
|
2021-03-17 16:11:39 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import AKGlobal from "../../../authentik.css";
|
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
2021-03-17 18:00:57 +00:00
|
|
|
import PFCard from "@patternfly/patternfly/components/Card/card.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
2021-03-17 18:00:57 +00:00
|
|
|
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
|
|
import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
2021-03-17 18:00:57 +00:00
|
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
2021-09-21 09:31:37 +00:00
|
|
|
import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css";
|
|
|
|
import PFFlex from "@patternfly/patternfly/utilities/Flex/flex.css";
|
|
|
|
import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css";
|
2021-02-09 15:17:59 +00:00
|
|
|
|
2021-09-21 09:31:37 +00:00
|
|
|
import { OAuthSource, SourcesApi } from "@goauthentik/api";
|
|
|
|
|
|
|
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
|
|
|
import { EVENT_REFRESH } from "../../../constants";
|
2021-04-02 09:27:49 +00:00
|
|
|
import "../../../elements/CodeMirror";
|
|
|
|
import "../../../elements/Tabs";
|
2021-09-21 09:31:37 +00:00
|
|
|
import "../../../elements/buttons/SpinnerButton";
|
2021-04-02 09:27:49 +00:00
|
|
|
import "../../../elements/events/ObjectChangelog";
|
2021-04-02 13:15:19 +00:00
|
|
|
import "../../../elements/forms/ModalForm";
|
2021-04-04 19:03:57 +00:00
|
|
|
import "../../policies/BoundPoliciesList";
|
2021-04-02 13:15:19 +00:00
|
|
|
import "./OAuthSourceForm";
|
2021-02-09 15:17:59 +00:00
|
|
|
|
|
|
|
@customElement("ak-source-oauth-view")
|
2021-04-10 15:06:54 +00:00
|
|
|
export class OAuthSourceViewPage extends LitElement {
|
2021-02-09 15:17:59 +00:00
|
|
|
@property({ type: String })
|
2021-02-09 15:47:49 +00:00
|
|
|
set sourceSlug(value: string) {
|
2021-08-03 15:52:21 +00:00
|
|
|
new SourcesApi(DEFAULT_CONFIG)
|
|
|
|
.sourcesOauthRetrieve({
|
|
|
|
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-08-03 15:52:21 +00:00
|
|
|
return [
|
|
|
|
PFBase,
|
|
|
|
PFPage,
|
|
|
|
PFButton,
|
|
|
|
PFFlex,
|
|
|
|
PFDisplay,
|
|
|
|
PFGallery,
|
|
|
|
PFContent,
|
|
|
|
PFCard,
|
|
|
|
PFDescriptionList,
|
|
|
|
PFSizing,
|
|
|
|
AKGlobal,
|
|
|
|
];
|
2021-02-09 15:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2021-03-23 14:16:56 +00:00
|
|
|
this.addEventListener(EVENT_REFRESH, () => {
|
2021-02-09 15:17:59 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-10 15:06:54 +00:00
|
|
|
render(): TemplateResult {
|
2021-02-09 15:17:59 +00:00
|
|
|
if (!this.source) {
|
|
|
|
return html``;
|
|
|
|
}
|
|
|
|
return html`<ak-tabs>
|
2021-08-03 15:52:21 +00:00
|
|
|
<section
|
|
|
|
slot="page-overview"
|
|
|
|
data-tab-title="${t`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">
|
|
|
|
<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`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">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Provider Type`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.source.providerType}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Callback URL`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<code class="pf-c-description-list__text"
|
|
|
|
>${this.source.callbackUrl}</code
|
|
|
|
>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Access Key`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.source.consumerKey}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Authorization URL`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.source.type?.authorizationUrl ||
|
|
|
|
this.source.authorizationUrl}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-description-list__group">
|
|
|
|
<dt class="pf-c-description-list__term">
|
|
|
|
<span class="pf-c-description-list__text"
|
|
|
|
>${t`Token URL`}</span
|
|
|
|
>
|
|
|
|
</dt>
|
|
|
|
<dd class="pf-c-description-list__description">
|
|
|
|
<div class="pf-c-description-list__text">
|
|
|
|
${this.source.type?.accessTokenUrl ||
|
|
|
|
this.source.accessTokenUrl}
|
|
|
|
</div>
|
|
|
|
</dd>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__footer">
|
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
|
|
<span slot="header"> ${t`Update OAuth Source`} </span>
|
|
|
|
<ak-source-oauth-form
|
|
|
|
slot="form"
|
|
|
|
.instancePk=${this.source.slug}
|
|
|
|
>
|
|
|
|
</ak-source-oauth-form>
|
|
|
|
<button slot="trigger" class="pf-c-button pf-m-primary">
|
|
|
|
${t`Edit`}
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
2021-02-09 15:17:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section
|
|
|
|
slot="page-changelog"
|
|
|
|
data-tab-title="${t`Changelog`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-object-changelog
|
|
|
|
targetModelPk=${this.source.pk || ""}
|
|
|
|
targetModelApp="authentik_sources_oauth"
|
|
|
|
targetModelName="oauthsource"
|
|
|
|
>
|
|
|
|
</ak-object-changelog>
|
2021-03-20 14:52:57 +00:00
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<div
|
|
|
|
slot="page-policy-binding"
|
|
|
|
data-tab-title="${t`Policy Bindings`}"
|
|
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
|
|
>
|
|
|
|
<div class="pf-c-card">
|
|
|
|
<div class="pf-c-card__title">
|
|
|
|
${t`These bindings control which users can access this source.
|
|
|
|
You can only use policies here as access is checked before the user is authenticated.`}
|
|
|
|
</div>
|
|
|
|
<div class="pf-c-card__body">
|
|
|
|
<ak-bound-policies-list .target=${this.source.pk} ?policyOnly=${true}>
|
|
|
|
</ak-bound-policies-list>
|
2021-04-04 19:03:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>
|
|
|
|
</ak-tabs>`;
|
2021-02-09 15:17:59 +00:00
|
|
|
}
|
|
|
|
}
|