diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index 3968e3b6f..a9c271a82 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -1,10 +1,11 @@ """Flow Stage API Views""" from typing import Iterable +from django.urls.base import reverse from drf_spectacular.utils import extend_schema from rest_framework import mixins from rest_framework.decorators import action -from rest_framework.fields import BooleanField +from rest_framework.fields import BooleanField, CharField from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import ModelSerializer, SerializerMethodField @@ -23,7 +24,7 @@ LOGGER = get_logger() class StageUserSettingSerializer(UserSettingSerializer): """User settings but can include a configure flow""" - configure_flow = BooleanField(required=False) + configure_flow = CharField(required=False) class StageSerializer(ModelSerializer, MetaNameSerializer): @@ -98,8 +99,8 @@ class StageViewSet( continue user_settings.initial_data["object_uid"] = str(stage.pk) if hasattr(stage, "configure_flow"): - user_settings.initial_data["configure_flow"] = bool( - stage.configure_flow + user_settings.initial_data["configure_flow"] = reverse( + "authentik_flows:configure", kwargs={"stage_uuid": stage.uuid.hex}, ) if not user_settings.is_valid(): LOGGER.warning(user_settings.errors) diff --git a/schema.yml b/schema.yml index a41aebd15..ab60c6026 100644 --- a/schema.yml +++ b/schema.yml @@ -25100,7 +25100,7 @@ components: title: type: string configure_flow: - type: boolean + type: string required: - component - object_uid diff --git a/web/src/api/legacy.ts b/web/src/api/legacy.ts index e0d458bcf..c6f5d209e 100644 --- a/web/src/api/legacy.ts +++ b/web/src/api/legacy.ts @@ -8,11 +8,3 @@ export class AppURLManager { } } - -export class FlowURLManager { - - static configure(stageUuid: string, rest: string): string { - return `/flows/-/configure/${stageUuid}/${rest}`; - } - -} diff --git a/web/src/pages/user-settings/UserSettingsPage.ts b/web/src/pages/user-settings/UserSettingsPage.ts index 73fa08c45..1e45700cb 100644 --- a/web/src/pages/user-settings/UserSettingsPage.ts +++ b/web/src/pages/user-settings/UserSettingsPage.ts @@ -38,19 +38,19 @@ export class UserSettingsPage extends LitElement { renderStageSettings(stage: StageUserSetting): TemplateResult { switch (stage.component) { case "ak-user-settings-authenticator-webauthn": - return html` + return html` `; case "ak-user-settings-password": return html` `; case "ak-user-settings-authenticator-totp": - return html` + return html` `; case "ak-user-settings-authenticator-static": - return html` + return html` `; case "ak-user-settings-authenticator-duo": - return html` + return html` `; default: return html`

${t`Error: unsupported stage settings: ${stage.component}`}

`; diff --git a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorDuo.ts b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorDuo.ts index 9bfc97c95..450750dc3 100644 --- a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorDuo.ts +++ b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorDuo.ts @@ -3,14 +3,13 @@ import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { until } from "lit-html/directives/until"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { FlowURLManager } from "../../../api/legacy"; import { BaseUserSettings } from "./BaseUserSettings"; @customElement("ak-user-settings-authenticator-duo") export class UserSettingsAuthenticatorDuo extends BaseUserSettings { - @property({ type: Boolean }) - configureFlow = false; + @property() + configureFlow?: string; renderEnabled(): TemplateResult { return html`
@@ -50,7 +49,7 @@ export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
`; diff --git a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorStatic.ts b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorStatic.ts index 09a8f67cb..07c3420a8 100644 --- a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorStatic.ts +++ b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorStatic.ts @@ -3,15 +3,14 @@ import { t } from "@lingui/macro"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; import { until } from "lit-html/directives/until"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { FlowURLManager } from "../../../api/legacy"; import { STATIC_TOKEN_STYLE } from "../../../flows/stages/authenticator_static/AuthenticatorStaticStage"; import { BaseUserSettings } from "./BaseUserSettings"; @customElement("ak-user-settings-authenticator-static") export class UserSettingsAuthenticatorStatic extends BaseUserSettings { - @property({ type: Boolean }) - configureFlow = false; + @property() + configureFlow?: string; static get styles(): CSSResult[] { return super.styles.concat(STATIC_TOKEN_STYLE); @@ -65,7 +64,7 @@ export class UserSettingsAuthenticatorStatic extends BaseUserSettings { `; diff --git a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorTOTP.ts b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorTOTP.ts index 0c9fd7986..e3dc2e199 100644 --- a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorTOTP.ts +++ b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorTOTP.ts @@ -3,14 +3,13 @@ import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { until } from "lit-html/directives/until"; import { DEFAULT_CONFIG } from "../../../api/Config"; -import { FlowURLManager } from "../../../api/legacy"; import { BaseUserSettings } from "./BaseUserSettings"; @customElement("ak-user-settings-authenticator-totp") export class UserSettingsAuthenticatorTOTP extends BaseUserSettings { - @property({ type: Boolean }) - configureFlow = false; + @property() + configureFlow?: string; renderEnabled(): TemplateResult { return html`
@@ -50,7 +49,7 @@ export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
`; diff --git a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorWebAuthn.ts b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorWebAuthn.ts index 1772a9112..028f265b8 100644 --- a/web/src/pages/user-settings/settings/UserSettingsAuthenticatorWebAuthn.ts +++ b/web/src/pages/user-settings/settings/UserSettingsAuthenticatorWebAuthn.ts @@ -2,7 +2,6 @@ import { CSSResult, customElement, html, property, TemplateResult } from "lit-el import { t } from "@lingui/macro"; import { AuthenticatorsApi, WebAuthnDevice } from "authentik-api"; import { until } from "lit-html/directives/until"; -import { FlowURLManager } from "../../../api/legacy"; import { DEFAULT_CONFIG } from "../../../api/Config"; import { BaseUserSettings } from "./BaseUserSettings"; import PFDataList from "@patternfly/patternfly/components/DataList/data-list.css"; @@ -17,8 +16,8 @@ import { ifDefined } from "lit-html/directives/if-defined"; @customElement("ak-user-settings-authenticator-webauthn") export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings { - @property({type: Boolean}) - configureFlow = false; + @property() + configureFlow?: string; static get styles(): CSSResult[] { return super.styles.concat(PFDataList); @@ -102,7 +101,7 @@ export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {