stages: authenticator_endpoint_gdtc (#10477)
* rework Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add loading overlay for chrome Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * Apply suggestions from code review Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com> Signed-off-by: Jens L. <jens@beryju.org> * save data Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix web ui, prevent deletion Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * text fixes Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Signed-off-by: Jens L. <jens@beryju.org> Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
This commit is contained in:
		@ -1,8 +1,9 @@
 | 
			
		||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
 | 
			
		||||
import { SentryIgnoredError } from "@goauthentik/common/errors";
 | 
			
		||||
import "@goauthentik/elements/forms/HorizontalFormElement";
 | 
			
		||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
 | 
			
		||||
 | 
			
		||||
import { msg } from "@lit/localize";
 | 
			
		||||
import { msg, str } from "@lit/localize";
 | 
			
		||||
import { TemplateResult, html } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators.js";
 | 
			
		||||
import { ifDefined } from "lit/directives/if-defined.js";
 | 
			
		||||
@ -10,11 +11,11 @@ import { ifDefined } from "lit/directives/if-defined.js";
 | 
			
		||||
import { AuthenticatorsApi, Device } from "@goauthentik/api";
 | 
			
		||||
 | 
			
		||||
@customElement("ak-user-mfa-form")
 | 
			
		||||
export class MFADeviceForm extends ModelForm<Device, number> {
 | 
			
		||||
export class MFADeviceForm extends ModelForm<Device, string> {
 | 
			
		||||
    @property()
 | 
			
		||||
    deviceType!: string;
 | 
			
		||||
 | 
			
		||||
    async loadInstance(pk: number): Promise<Device> {
 | 
			
		||||
    async loadInstance(pk: string): Promise<Device> {
 | 
			
		||||
        const devices = await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList();
 | 
			
		||||
        return devices.filter((device) => {
 | 
			
		||||
            return device.pk === pk && device.type === this.deviceType;
 | 
			
		||||
@ -29,36 +30,38 @@ export class MFADeviceForm extends ModelForm<Device, number> {
 | 
			
		||||
        switch (this.instance?.type) {
 | 
			
		||||
            case "authentik_stages_authenticator_duo.DuoDevice":
 | 
			
		||||
                await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoUpdate({
 | 
			
		||||
                    id: this.instance?.pk,
 | 
			
		||||
                    id: parseInt(this.instance?.pk, 10),
 | 
			
		||||
                    duoDeviceRequest: device,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "authentik_stages_authenticator_sms.SMSDevice":
 | 
			
		||||
                await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsSmsUpdate({
 | 
			
		||||
                    id: this.instance?.pk,
 | 
			
		||||
                    id: parseInt(this.instance?.pk, 10),
 | 
			
		||||
                    sMSDeviceRequest: device,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "authentik_stages_authenticator_totp.TOTPDevice":
 | 
			
		||||
                await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsTotpUpdate({
 | 
			
		||||
                    id: this.instance?.pk,
 | 
			
		||||
                    id: parseInt(this.instance?.pk, 10),
 | 
			
		||||
                    tOTPDeviceRequest: device,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "authentik_stages_authenticator_static.StaticDevice":
 | 
			
		||||
                await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsStaticUpdate({
 | 
			
		||||
                    id: this.instance?.pk,
 | 
			
		||||
                    id: parseInt(this.instance?.pk, 10),
 | 
			
		||||
                    staticDeviceRequest: device,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "authentik_stages_authenticator_webauthn.WebAuthnDevice":
 | 
			
		||||
                await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsWebauthnUpdate({
 | 
			
		||||
                    id: this.instance?.pk,
 | 
			
		||||
                    id: parseInt(this.instance?.pk, 10),
 | 
			
		||||
                    webAuthnDeviceRequest: device,
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
                throw new SentryIgnoredError(
 | 
			
		||||
                    msg(str`Device type ${device.verboseName} cannot be edited`),
 | 
			
		||||
                );
 | 
			
		||||
        }
 | 
			
		||||
        return device;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user