core: add configure_url to UserSettings for both stages and sources
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -8,7 +8,6 @@ import "../../../elements/forms/HorizontalFormElement";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { first } from "../../../utils";
|
||||
import { AppURLManager } from "../../../api/legacy";
|
||||
import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||
|
||||
@customElement("ak-source-oauth-form")
|
||||
@ -95,14 +94,6 @@ export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
|
||||
</ak-form-group>`;
|
||||
}
|
||||
|
||||
getRedirectURI(slug?: string): string {
|
||||
if (!slug) {
|
||||
return "";
|
||||
}
|
||||
const path = AppURLManager.sourceOAuth(slug, "callback");
|
||||
return `${window.location.protocol}//${window.location.host}${path}`;
|
||||
}
|
||||
|
||||
renderForm(): TemplateResult {
|
||||
return html`<form class="pf-c-form pf-m-horizontal">
|
||||
<ak-form-element-horizontal
|
||||
@ -115,16 +106,7 @@ export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
|
||||
label=${t`Slug`}
|
||||
?required=${true}
|
||||
name="slug">
|
||||
<input type="text" value="${ifDefined(this.instance?.slug)}" class="pf-c-form-control" required @input=${(ev: Event) => {
|
||||
const current = (ev.target as HTMLInputElement).value;
|
||||
const label = this.shadowRoot?.querySelector<HTMLSpanElement>("#callback-url");
|
||||
if (!label) return;
|
||||
label.innerText = this.getRedirectURI(current);
|
||||
}}>
|
||||
<p class="pf-c-form__helper-text">
|
||||
${t`Use this redirect URL:`}
|
||||
<span id="callback-url">${this.getRedirectURI(this.instance?.slug)}</span>
|
||||
</p>
|
||||
<input type="text" value="${ifDefined(this.instance?.slug)}" class="pf-c-form-control" required>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal name="enabled">
|
||||
<div class="pf-c-check">
|
||||
|
||||
@ -13,7 +13,7 @@ import AKGlobal from "../../authentik.css";
|
||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||
import PFForm from "@patternfly/patternfly/components/Form/form.css";
|
||||
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
|
||||
import { SourcesApi, StagesApi, StageUserSetting, UserSetting } from "authentik-api";
|
||||
import { SourcesApi, StagesApi, UserSetting } from "authentik-api";
|
||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
@ -35,22 +35,22 @@ export class UserSettingsPage extends LitElement {
|
||||
return [PFBase, PFPage, PFFlex, PFDisplay, PFGallery, PFContent, PFCard, PFDescriptionList, PFSizing, PFForm, PFFormControl, AKGlobal];
|
||||
}
|
||||
|
||||
renderStageSettings(stage: StageUserSetting): TemplateResult {
|
||||
renderStageSettings(stage: UserSetting): TemplateResult {
|
||||
switch (stage.component) {
|
||||
case "ak-user-settings-authenticator-webauthn":
|
||||
return html`<ak-user-settings-authenticator-webauthn objectId=${stage.objectUid} configureFlow=${stage.configureFlow}>
|
||||
return html`<ak-user-settings-authenticator-webauthn objectId=${stage.objectUid} configureUrl=${stage.configureUrl}>
|
||||
</ak-user-settings-authenticator-webauthn>`;
|
||||
case "ak-user-settings-password":
|
||||
return html`<ak-user-settings-password objectId=${stage.objectUid}>
|
||||
return html`<ak-user-settings-password objectId=${stage.objectUid} configureUrl=${stage.configureUrl}>
|
||||
</ak-user-settings-password>`;
|
||||
case "ak-user-settings-authenticator-totp":
|
||||
return html`<ak-user-settings-authenticator-totp objectId=${stage.objectUid} configureFlow=${stage.configureFlow}>
|
||||
return html`<ak-user-settings-authenticator-totp objectId=${stage.objectUid} configureUrl=${stage.configureUrl}>
|
||||
</ak-user-settings-authenticator-totp>`;
|
||||
case "ak-user-settings-authenticator-static":
|
||||
return html`<ak-user-settings-authenticator-static objectId=${stage.objectUid} configureFlow=${stage.configureFlow}>
|
||||
return html`<ak-user-settings-authenticator-static objectId=${stage.objectUid} configureUrl=${stage.configureUrl}>
|
||||
</ak-user-settings-authenticator-static>`;
|
||||
case "ak-user-settings-authenticator-duo":
|
||||
return html`<ak-user-settings-authenticator-duo objectId=${stage.objectUid} configureFlow=${stage.configureFlow}>
|
||||
return html`<ak-user-settings-authenticator-duo objectId=${stage.objectUid} configureUrl=${stage.configureUrl}>
|
||||
</ak-user-settings-authenticator-duo>`;
|
||||
default:
|
||||
return html`<p>${t`Error: unsupported stage settings: ${stage.component}`}</p>`;
|
||||
@ -60,7 +60,7 @@ export class UserSettingsPage extends LitElement {
|
||||
renderSourceSettings(source: UserSetting): TemplateResult {
|
||||
switch (source.component) {
|
||||
case "ak-user-settings-source-oauth":
|
||||
return html`<ak-user-settings-source-oauth objectId=${source.objectUid} title=${source.title}>
|
||||
return html`<ak-user-settings-source-oauth objectId=${source.objectUid} title=${source.title} configureUrl=${source.configureUrl}>
|
||||
</ak-user-settings-source-oauth>`;
|
||||
default:
|
||||
return html`<p>${t`Error: unsupported source settings: ${source.component}`}</p>`;
|
||||
|
||||
@ -11,6 +11,9 @@ export abstract class BaseUserSettings extends LitElement {
|
||||
@property()
|
||||
objectId!: string;
|
||||
|
||||
@property()
|
||||
configureUrl?: string;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [PFBase, PFCard, PFButton, PFForm, PFFormControl, AKGlobal];
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { SourcesApi } from "authentik-api";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||
import { t } from "@lingui/macro";
|
||||
import { AppURLManager } from "../../../api/legacy";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
|
||||
@customElement("ak-user-settings-source-oauth")
|
||||
export class SourceSettingsOAuth extends BaseUserSettings {
|
||||
@ -40,7 +40,7 @@ export class SourceSettingsOAuth extends BaseUserSettings {
|
||||
}
|
||||
return html`<p>${t`Not connected.`}</p>
|
||||
<a class="pf-c-button pf-m-primary"
|
||||
href=${AppURLManager.sourceOAuth(this.objectId, "login")}>
|
||||
href=${ifDefined(this.configureUrl)}>
|
||||
${t`Connect`}
|
||||
</a>`;
|
||||
}))}`;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { AuthenticatorsApi } from "authentik-api";
|
||||
import { t } from "@lingui/macro";
|
||||
import { customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { customElement, html, TemplateResult } from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||
import { BaseUserSettings } from "./BaseUserSettings";
|
||||
@ -8,9 +8,6 @@ import { BaseUserSettings } from "./BaseUserSettings";
|
||||
@customElement("ak-user-settings-authenticator-duo")
|
||||
export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
|
||||
|
||||
@property()
|
||||
configureFlow?: string;
|
||||
|
||||
renderEnabled(): TemplateResult {
|
||||
return html`<div class="pf-c-card__body">
|
||||
<p>
|
||||
@ -48,8 +45,8 @@ export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
|
||||
</p>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
${this.configureFlow ?
|
||||
html`<a href="${this.configureFlow}?next=/%23%2Fuser"
|
||||
${this.configureUrl ?
|
||||
html`<a href="${this.configureUrl}?next=/%23%2Fuser"
|
||||
class="pf-c-button pf-m-primary">${t`Enable Static Tokens`}
|
||||
</a>`: html``}
|
||||
</div>`;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { AuthenticatorsApi } from "authentik-api";
|
||||
import { t } from "@lingui/macro";
|
||||
import { CSSResult, customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { CSSResult, customElement, html, TemplateResult } from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||
import { STATIC_TOKEN_STYLE } from "../../../flows/stages/authenticator_static/AuthenticatorStaticStage";
|
||||
@ -9,9 +9,6 @@ import { BaseUserSettings } from "./BaseUserSettings";
|
||||
@customElement("ak-user-settings-authenticator-static")
|
||||
export class UserSettingsAuthenticatorStatic extends BaseUserSettings {
|
||||
|
||||
@property()
|
||||
configureFlow?: string;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return super.styles.concat(STATIC_TOKEN_STYLE);
|
||||
}
|
||||
@ -63,8 +60,8 @@ export class UserSettingsAuthenticatorStatic extends BaseUserSettings {
|
||||
</p>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
${this.configureFlow ?
|
||||
html`<a href="${this.configureFlow}?next=/%23%2Fuser"
|
||||
${this.configureUrl ?
|
||||
html`<a href="${this.configureUrl}?next=/%23%2Fuser"
|
||||
class="pf-c-button pf-m-primary">${t`Enable Static Tokens`}
|
||||
</a>`: html``}
|
||||
</div>`;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { AuthenticatorsApi } from "authentik-api";
|
||||
import { t } from "@lingui/macro";
|
||||
import { customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { customElement, html, TemplateResult } from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||
import { BaseUserSettings } from "./BaseUserSettings";
|
||||
@ -8,9 +8,6 @@ import { BaseUserSettings } from "./BaseUserSettings";
|
||||
@customElement("ak-user-settings-authenticator-totp")
|
||||
export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
|
||||
|
||||
@property()
|
||||
configureFlow?: string;
|
||||
|
||||
renderEnabled(): TemplateResult {
|
||||
return html`<div class="pf-c-card__body">
|
||||
<p>
|
||||
@ -48,8 +45,8 @@ export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
|
||||
</p>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
${this.configureFlow ?
|
||||
html`<a href="${this.configureFlow}?next=/%23%2Fuser"
|
||||
${this.configureUrl ?
|
||||
html`<a href="${this.configureUrl}?next=/%23%2Fuser"
|
||||
class="pf-c-button pf-m-primary">${t`Enable TOTP`}
|
||||
</a>`: html``}
|
||||
</div>`;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { CSSResult, customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { CSSResult, customElement, html, TemplateResult } from "lit-element";
|
||||
import { t } from "@lingui/macro";
|
||||
import { AuthenticatorsApi, WebAuthnDevice } from "authentik-api";
|
||||
import { until } from "lit-html/directives/until";
|
||||
@ -16,9 +16,6 @@ import { ifDefined } from "lit-html/directives/if-defined";
|
||||
@customElement("ak-user-settings-authenticator-webauthn")
|
||||
export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {
|
||||
|
||||
@property()
|
||||
configureFlow?: string;
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return super.styles.concat(PFDataList);
|
||||
}
|
||||
@ -100,8 +97,8 @@ export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {
|
||||
</ul>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
${this.configureFlow ?
|
||||
html`<a href="${this.configureFlow}?next=/%23%2Fuser"
|
||||
${this.configureUrl ?
|
||||
html`<a href="${this.configureUrl}?next=/%23%2Fuser"
|
||||
class="pf-c-button pf-m-primary">${t`Configure WebAuthn`}
|
||||
</a>`: html``}
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { customElement, html, TemplateResult } from "lit-element";
|
||||
import { t } from "@lingui/macro";
|
||||
import { FlowURLManager } from "../../../api/legacy";
|
||||
import { BaseUserSettings } from "./BaseUserSettings";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
|
||||
@customElement("ak-user-settings-password")
|
||||
export class UserSettingsPassword extends BaseUserSettings {
|
||||
@ -14,7 +14,7 @@ export class UserSettingsPassword extends BaseUserSettings {
|
||||
${t`Change your password`}
|
||||
</div>
|
||||
<div class="pf-c-card__body">
|
||||
<a href="${FlowURLManager.configure(this.objectId, "?next=/%23%2Fuser")}"
|
||||
<a href="${ifDefined(this.configureUrl)}"
|
||||
class="pf-c-button pf-m-primary">
|
||||
${t`Change password`}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user