diff --git a/authentik/core/api/devices.py b/authentik/core/api/devices.py index 777361533..b5e0b8165 100644 --- a/authentik/core/api/devices.py +++ b/authentik/core/api/devices.py @@ -1,7 +1,7 @@ """Authenticator Devices API Views""" from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema -from rest_framework.fields import BooleanField, CharField, IntegerField, SerializerMethodField +from rest_framework.fields import BooleanField, CharField, SerializerMethodField from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.request import Request from rest_framework.response import Response @@ -15,10 +15,10 @@ from authentik.stages.authenticator.models import Device class DeviceSerializer(MetaNameSerializer): """Serializer for Duo authenticator devices""" - pk = IntegerField() + pk = CharField() name = CharField() type = SerializerMethodField() - confirmed = BooleanField() + confirmed = BooleanField(read_only=True) def get_type(self, instance: Device) -> str: """Get type of device""" diff --git a/authentik/stages/authenticator_duo/api.py b/authentik/stages/authenticator_duo/api.py index 3d038de31..2cf4329c9 100644 --- a/authentik/stages/authenticator_duo/api.py +++ b/authentik/stages/authenticator_duo/api.py @@ -11,12 +11,12 @@ from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser from rest_framework.request import Request from rest_framework.response import Response -from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from structlog.stdlib import get_logger from authentik.api.authorization import OwnerFilter, OwnerPermissions from authentik.api.decorators import permission_required +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.flows.api.stages import StageSerializer from authentik.stages.authenticator_duo.models import AuthenticatorDuoStage, DuoDevice @@ -165,7 +165,7 @@ class AuthenticatorDuoStageViewSet(UsedByMixin, ModelViewSet): return Response(data=result, status=200 if result["error"] == "" else 400) -class DuoDeviceSerializer(ModelSerializer): +class DuoDeviceSerializer(DeviceSerializer): """Serializer for Duo authenticator devices""" class Meta: diff --git a/authentik/stages/authenticator_mobile/api/device.py b/authentik/stages/authenticator_mobile/api/device.py index d0927afb8..12672278f 100644 --- a/authentik/stages/authenticator_mobile/api/device.py +++ b/authentik/stages/authenticator_mobile/api/device.py @@ -10,10 +10,10 @@ from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser from rest_framework.request import Request from rest_framework.response import Response -from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from authentik.api.authorization import OwnerFilter, OwnerPermissions +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import PassiveSerializer from authentik.stages.authenticator_mobile.api.auth import MobileDeviceTokenAuthentication @@ -36,7 +36,7 @@ class MobileDeviceInfoSerializer(PassiveSerializer): others = JSONField() -class MobileDeviceSerializer(ModelSerializer): +class MobileDeviceSerializer(DeviceSerializer): """Serializer for Mobile authenticator devices""" last_checkin = MobileDeviceInfoSerializer(read_only=True) diff --git a/authentik/stages/authenticator_sms/api.py b/authentik/stages/authenticator_sms/api.py index bfa0b323e..ca47bac94 100644 --- a/authentik/stages/authenticator_sms/api.py +++ b/authentik/stages/authenticator_sms/api.py @@ -3,10 +3,10 @@ from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework import mixins from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser -from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from authentik.api.authorization import OwnerFilter, OwnerPermissions +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.flows.api.stages import StageSerializer from authentik.stages.authenticator_sms.models import AuthenticatorSMSStage, SMSDevice @@ -41,7 +41,7 @@ class AuthenticatorSMSStageViewSet(UsedByMixin, ModelViewSet): search_fields = ["name"] -class SMSDeviceSerializer(ModelSerializer): +class SMSDeviceSerializer(DeviceSerializer): """Serializer for sms authenticator devices""" class Meta: diff --git a/authentik/stages/authenticator_static/api.py b/authentik/stages/authenticator_static/api.py index d9f474eb1..d7e686cf4 100644 --- a/authentik/stages/authenticator_static/api.py +++ b/authentik/stages/authenticator_static/api.py @@ -7,6 +7,7 @@ from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from authentik.api.authorization import OwnerFilter, OwnerPermissions +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.flows.api.stages import StageSerializer from authentik.stages.authenticator_static.models import ( @@ -47,7 +48,7 @@ class StaticDeviceTokenSerializer(ModelSerializer): fields = ["token"] -class StaticDeviceSerializer(ModelSerializer): +class StaticDeviceSerializer(DeviceSerializer): """Serializer for static authenticator devices""" token_set = StaticDeviceTokenSerializer(many=True, read_only=True) diff --git a/authentik/stages/authenticator_totp/api.py b/authentik/stages/authenticator_totp/api.py index 3baffb3ff..3bb34dc94 100644 --- a/authentik/stages/authenticator_totp/api.py +++ b/authentik/stages/authenticator_totp/api.py @@ -4,10 +4,10 @@ from rest_framework import mixins from rest_framework.fields import ChoiceField from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser -from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from authentik.api.authorization import OwnerFilter, OwnerPermissions +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.flows.api.stages import StageSerializer from authentik.stages.authenticator_totp.models import ( @@ -37,7 +37,7 @@ class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet): search_fields = ["name"] -class TOTPDeviceSerializer(ModelSerializer): +class TOTPDeviceSerializer(DeviceSerializer): """Serializer for totp authenticator devices""" class Meta: diff --git a/authentik/stages/authenticator_webauthn/api.py b/authentik/stages/authenticator_webauthn/api.py index 9d1914353..f123303dc 100644 --- a/authentik/stages/authenticator_webauthn/api.py +++ b/authentik/stages/authenticator_webauthn/api.py @@ -3,10 +3,10 @@ from django_filters.rest_framework.backends import DjangoFilterBackend from rest_framework import mixins from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser -from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet, ModelViewSet from authentik.api.authorization import OwnerFilter, OwnerPermissions +from authentik.core.api.devices import DeviceSerializer from authentik.core.api.used_by import UsedByMixin from authentik.flows.api.stages import StageSerializer from authentik.stages.authenticator_webauthn.models import AuthenticateWebAuthnStage, WebAuthnDevice @@ -36,7 +36,7 @@ class AuthenticateWebAuthnStageViewSet(UsedByMixin, ModelViewSet): search_fields = ["name"] -class WebAuthnDeviceSerializer(ModelSerializer): +class WebAuthnDeviceSerializer(DeviceSerializer): """Serializer for WebAuthn authenticator devices""" class Meta: diff --git a/blueprints/schema.json b/blueprints/schema.json index b2ba6736d..e10eef273 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -6031,12 +6031,15 @@ "model_authentik_stages_authenticator_duo.duodevice": { "type": "object", "properties": { + "pk": { + "type": "string", + "minLength": 1, + "title": "Pk" + }, "name": { "type": "string", - "maxLength": 64, "minLength": 1, - "title": "Name", - "description": "The human-readable name of this device." + "title": "Name" } }, "required": [] @@ -6166,20 +6169,13 @@ "properties": { "pk": { "type": "string", - "format": "uuid", - "title": "Uuid" + "minLength": 1, + "title": "Pk" }, "name": { "type": "string", - "maxLength": 64, "minLength": 1, - "title": "Name", - "description": "The human-readable name of this device." - }, - "state": { - "type": "object", - "additionalProperties": true, - "title": "State" + "title": "Name" } }, "required": [] @@ -6338,12 +6334,15 @@ "model_authentik_stages_authenticator_sms.smsdevice": { "type": "object", "properties": { + "pk": { + "type": "string", + "minLength": 1, + "title": "Pk" + }, "name": { "type": "string", - "maxLength": 64, "minLength": 1, - "title": "Name", - "description": "The human-readable name of this device." + "title": "Name" } }, "required": [] @@ -6469,12 +6468,15 @@ "model_authentik_stages_authenticator_static.staticdevice": { "type": "object", "properties": { + "pk": { + "type": "string", + "minLength": 1, + "title": "Pk" + }, "name": { "type": "string", - "maxLength": 64, "minLength": 1, - "title": "Name", - "description": "The human-readable name of this device." + "title": "Name" } }, "required": [] @@ -6596,12 +6598,15 @@ "model_authentik_stages_authenticator_totp.totpdevice": { "type": "object", "properties": { + "pk": { + "type": "string", + "minLength": 1, + "title": "Pk" + }, "name": { "type": "string", - "maxLength": 64, "minLength": 1, - "title": "Name", - "description": "The human-readable name of this device." + "title": "Name" } }, "required": [] @@ -6889,9 +6894,13 @@ "model_authentik_stages_authenticator_webauthn.webauthndevice": { "type": "object", "properties": { + "pk": { + "type": "string", + "minLength": 1, + "title": "Pk" + }, "name": { "type": "string", - "maxLength": 200, "minLength": 1, "title": "Name" } diff --git a/schema.yml b/schema.yml index c546a79e3..14002dcb8 100644 --- a/schema.yml +++ b/schema.yml @@ -31895,7 +31895,7 @@ components: description: Return internal model name readOnly: true pk: - type: integer + type: string name: type: string type: @@ -31904,6 +31904,7 @@ components: readOnly: true confirmed: type: boolean + readOnly: true required: - confirmed - meta_model_name @@ -32229,17 +32230,37 @@ components: type: object description: Serializer for Duo authenticator devices properties: - pk: - type: integer + verbose_name: + type: string + description: Return object's verbose_name readOnly: true - title: ID + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true + pk: + type: string name: type: string - description: The human-readable name of this device. - maxLength: 64 + type: + type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean + readOnly: true required: + - confirmed + - meta_model_name - name - pk + - type + - verbose_name + - verbose_name_plural DuoDeviceEnrollmentStatus: type: object properties: @@ -32251,13 +32272,15 @@ components: type: object description: Serializer for Duo authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 required: - name + - pk DuoResponseEnum: enum: - success @@ -35310,24 +35333,42 @@ components: type: object description: Serializer for Mobile authenticator devices properties: + verbose_name: + type: string + description: Return object's verbose_name + readOnly: true + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true pk: type: string - format: uuid - title: Uuid name: type: string - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} + type: + type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean + readOnly: true last_checkin: allOf: - $ref: '#/components/schemas/MobileDeviceInfo' readOnly: true required: + - confirmed - last_checkin + - meta_model_name - name + - pk + - type + - verbose_name + - verbose_name_plural MobileDeviceEnrollmentCallback: type: object properties: @@ -35420,18 +35461,13 @@ components: properties: pk: type: string - format: uuid - title: Uuid + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} required: - name + - pk MobileDeviceResponseRequest: type: object description: Response from push sent to phone @@ -38527,11 +38563,12 @@ components: type: object description: Serializer for Duo authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 PatchedEmailStageRequest: type: object description: EmailStage Serializer @@ -39291,16 +39328,10 @@ components: properties: pk: type: string - format: uuid - title: Uuid + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} PatchedNotificationRequest: type: object description: Notification Serializer @@ -40334,11 +40365,12 @@ components: type: object description: Serializer for sms authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 PatchedScopeMappingRequest: type: object description: ScopeMapping Serializer @@ -40370,20 +40402,22 @@ components: type: object description: Serializer for static authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 PatchedTOTPDeviceRequest: type: object description: Serializer for totp authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 PatchedTenantRequest: type: object description: Tenant Serializer @@ -40624,10 +40658,12 @@ components: type: object description: Serializer for WebAuthn authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - maxLength: 200 Permission: type: object description: Global permission @@ -43312,32 +43348,50 @@ components: type: object description: Serializer for sms authenticator devices properties: + verbose_name: + type: string + description: Return object's verbose_name + readOnly: true + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true + pk: + type: string name: type: string - description: The human-readable name of this device. - maxLength: 64 - pk: - type: integer - readOnly: true - title: ID - phone_number: + type: type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean readOnly: true required: + - confirmed + - meta_model_name - name - - phone_number - pk + - type + - verbose_name + - verbose_name_plural SMSDeviceRequest: type: object description: Serializer for sms authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 required: - name + - pk ScopeMapping: type: object description: ScopeMapping Serializer @@ -43835,34 +43889,56 @@ components: type: object description: Serializer for static authenticator devices properties: + verbose_name: + type: string + description: Return object's verbose_name + readOnly: true + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true + pk: + type: string name: type: string - description: The human-readable name of this device. - maxLength: 64 + type: + type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean + readOnly: true token_set: type: array items: $ref: '#/components/schemas/StaticDeviceToken' readOnly: true - pk: - type: integer - readOnly: true - title: ID required: + - confirmed + - meta_model_name - name - pk - token_set + - type + - verbose_name + - verbose_name_plural StaticDeviceRequest: type: object description: Serializer for static authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 required: - name + - pk StaticDeviceToken: type: object description: Serializer for static device's tokens @@ -43965,28 +44041,50 @@ components: type: object description: Serializer for totp authenticator devices properties: + verbose_name: + type: string + description: Return object's verbose_name + readOnly: true + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true + pk: + type: string name: type: string - description: The human-readable name of this device. - maxLength: 64 - pk: - type: integer + type: + type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean readOnly: true - title: ID required: + - confirmed + - meta_model_name - name - pk + - type + - verbose_name + - verbose_name_plural TOTPDeviceRequest: type: object description: Serializer for totp authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 required: - name + - pk Task: type: object description: Serialize TaskInfo and TaskResult @@ -45324,31 +45422,50 @@ components: type: object description: Serializer for WebAuthn authenticator devices properties: - pk: - type: integer + verbose_name: + type: string + description: Return object's verbose_name readOnly: true - title: ID + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true + pk: + type: string name: type: string - maxLength: 200 - created_on: + type: type: string - format: date-time + description: Get type of device + readOnly: true + confirmed: + type: boolean readOnly: true required: - - created_on + - confirmed + - meta_model_name - name - pk + - type + - verbose_name + - verbose_name_plural WebAuthnDeviceRequest: type: object description: Serializer for WebAuthn authenticator devices properties: + pk: + type: string + minLength: 1 name: type: string minLength: 1 - maxLength: 200 required: - name + - pk Workers: type: object properties: diff --git a/schemas/authentik-cloud-gateway.yml b/schemas/authentik-cloud-gateway.yml index d19e810aa..cdb265710 100644 --- a/schemas/authentik-cloud-gateway.yml +++ b/schemas/authentik-cloud-gateway.yml @@ -464,24 +464,42 @@ components: type: object description: Serializer for Mobile authenticator devices properties: + verbose_name: + type: string + description: Return object's verbose_name + readOnly: true + verbose_name_plural: + type: string + description: Return object's plural verbose_name + readOnly: true + meta_model_name: + type: string + description: Return internal model name + readOnly: true pk: type: string - format: uuid - title: Uuid name: type: string - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} + type: + type: string + description: Get type of device + readOnly: true + confirmed: + type: boolean + readOnly: true last_checkin: allOf: - $ref: '#/components/schemas/MobileDeviceInfo' readOnly: true required: + - confirmed - last_checkin + - meta_model_name - name + - pk + - type + - verbose_name + - verbose_name_plural MobileDeviceEnrollmentCallback: type: object properties: @@ -566,18 +584,13 @@ components: properties: pk: type: string - format: uuid - title: Uuid + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} required: - name + - pk MobileDeviceResponseRequest: type: object description: Response from push sent to phone @@ -643,16 +656,10 @@ components: properties: pk: type: string - format: uuid - title: Uuid + minLength: 1 name: type: string minLength: 1 - description: The human-readable name of this device. - maxLength: 64 - state: - type: object - additionalProperties: {} PlatformEnum: enum: - ios diff --git a/web/src/admin/users/UserDevicesTable.ts b/web/src/admin/users/UserDevicesTable.ts index 06ead21df..8fc0e1acc 100644 --- a/web/src/admin/users/UserDevicesTable.ts +++ b/web/src/admin/users/UserDevicesTable.ts @@ -49,18 +49,21 @@ export class UserDeviceTable extends Table { async deleteWrapper(device: Device) { const api = new AuthenticatorsApi(DEFAULT_CONFIG); - const id = { id: device.pk }; - switch (device.type) { - case "authentik_stages_authenticator_duo.DuoDevice": - return api.authenticatorsAdminDuoDestroy(id); - case "authentik_stages_authenticator_sms.SMSDevice": - return api.authenticatorsAdminSmsDestroy(id); - case "authentik_stages_authenticator_totp.TOTPDevice": - return api.authenticatorsAdminTotpDestroy(id); - case "authentik_stages_authenticator_static.StaticDevice": - return api.authenticatorsAdminStaticDestroy(id); - case "authentik_stages_authenticator_webauthn.WebAuthnDevice": - return api.authenticatorsAdminWebauthnDestroy(id); + switch (device.type.toLowerCase()) { + case "authentik_stages_authenticator_duo.duodevice": + return api.authenticatorsAdminDuoDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_sms.smsdevice": + return api.authenticatorsAdminSmsDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_totp.totpdevice": + return api.authenticatorsAdminTotpDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_static.staticdevice": + return api.authenticatorsAdminStaticDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_webauthn.webauthndevice": + return api.authenticatorsAdminWebauthnDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_mobile.mobiledevice": + return api.authenticatorsMobileDestroy({ + uuid: device.pk, + }); default: break; } diff --git a/web/src/user/user-settings/mfa/MFADeviceForm.ts b/web/src/user/user-settings/mfa/MFADeviceForm.ts index a418eeb02..c711d2ec6 100644 --- a/web/src/user/user-settings/mfa/MFADeviceForm.ts +++ b/web/src/user/user-settings/mfa/MFADeviceForm.ts @@ -10,11 +10,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 { +export class MFADeviceForm extends ModelForm { @property() deviceType!: string; - async loadInstance(pk: number): Promise { + async loadInstance(pk: string): Promise { const devices = await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList(); return devices.filter((device) => { return device.pk === pk && device.type === this.deviceType; @@ -26,37 +26,43 @@ export class MFADeviceForm extends ModelForm { } async send(device: Device): Promise { - switch (this.instance?.type) { - case "authentik_stages_authenticator_duo.DuoDevice": + switch (this.instance?.type.toLowerCase()) { + 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": + 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": + 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": + 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": + 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; + case "authentik_stages_authenticator_mobile.mobiledevice": + await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsMobileUpdate({ + uuid: this.instance?.pk, + mobileDeviceRequest: device, + }); + break; default: break; } diff --git a/web/src/user/user-settings/mfa/MFADevicesPage.ts b/web/src/user/user-settings/mfa/MFADevicesPage.ts index 4b05d6c64..318555721 100644 --- a/web/src/user/user-settings/mfa/MFADevicesPage.ts +++ b/web/src/user/user-settings/mfa/MFADevicesPage.ts @@ -85,21 +85,20 @@ export class MFADevicesPage extends Table { async deleteWrapper(device: Device) { const api = new AuthenticatorsApi(DEFAULT_CONFIG); - const id = { id: device.pk }; - switch (device.type) { - case "authentik_stages_authenticator_duo.DuoDevice": - return api.authenticatorsDuoDestroy(id); - case "authentik_stages_authenticator_sms.SMSDevice": - return api.authenticatorsSmsDestroy(id); - case "authentik_stages_authenticator_totp.TOTPDevice": - return api.authenticatorsTotpDestroy(id); - case "authentik_stages_authenticator_static.StaticDevice": - return api.authenticatorsStaticDestroy(id); - case "authentik_stages_authenticator_webauthn.WebAuthnDevice": - return api.authenticatorsWebauthnDestroy(id); + switch (device.type.toLowerCase()) { + case "authentik_stages_authenticator_duo.duodevice": + return api.authenticatorsDuoDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_sms.smsdevice": + return api.authenticatorsSmsDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_totp.totpdevice": + return api.authenticatorsTotpDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_static.staticdevice": + return api.authenticatorsStaticDestroy({ id: parseInt(device.pk, 10) }); + case "authentik_stages_authenticator_webauthn.webauthndevice": + return api.authenticatorsWebauthnDestroy({ id: parseInt(device.pk, 10) }); case "authentik_stages_authenticator_mobile.mobiledevice": return api.authenticatorsMobileDestroy({ - uuid: device.pk as unknown as string, + uuid: device.pk, }); default: break;