fix web to support string for device uuid

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-12-18 01:04:41 +01:00
parent adcfb3092e
commit c19e12d1e1
No known key found for this signature in database
13 changed files with 309 additions and 167 deletions

View File

@ -1,7 +1,7 @@
"""Authenticator Devices API Views""" """Authenticator Devices API Views"""
from drf_spectacular.types import OpenApiTypes from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema 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.permissions import IsAdminUser, IsAuthenticated
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
@ -15,10 +15,10 @@ from authentik.stages.authenticator.models import Device
class DeviceSerializer(MetaNameSerializer): class DeviceSerializer(MetaNameSerializer):
"""Serializer for Duo authenticator devices""" """Serializer for Duo authenticator devices"""
pk = IntegerField() pk = CharField()
name = CharField() name = CharField()
type = SerializerMethodField() type = SerializerMethodField()
confirmed = BooleanField() confirmed = BooleanField(read_only=True)
def get_type(self, instance: Device) -> str: def get_type(self, instance: Device) -> str:
"""Get type of device""" """Get type of device"""

View File

@ -11,12 +11,12 @@ from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAdminUser from rest_framework.permissions import IsAdminUser
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from authentik.api.authorization import OwnerFilter, OwnerPermissions from authentik.api.authorization import OwnerFilter, OwnerPermissions
from authentik.api.decorators import permission_required from authentik.api.decorators import permission_required
from authentik.core.api.devices import DeviceSerializer
from authentik.core.api.used_by import UsedByMixin from authentik.core.api.used_by import UsedByMixin
from authentik.flows.api.stages import StageSerializer from authentik.flows.api.stages import StageSerializer
from authentik.stages.authenticator_duo.models import AuthenticatorDuoStage, DuoDevice 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) return Response(data=result, status=200 if result["error"] == "" else 400)
class DuoDeviceSerializer(ModelSerializer): class DuoDeviceSerializer(DeviceSerializer):
"""Serializer for Duo authenticator devices""" """Serializer for Duo authenticator devices"""
class Meta: class Meta:

View File

@ -10,10 +10,10 @@ from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAdminUser from rest_framework.permissions import IsAdminUser
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from authentik.api.authorization import OwnerFilter, OwnerPermissions 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.used_by import UsedByMixin
from authentik.core.api.utils import PassiveSerializer from authentik.core.api.utils import PassiveSerializer
from authentik.stages.authenticator_mobile.api.auth import MobileDeviceTokenAuthentication from authentik.stages.authenticator_mobile.api.auth import MobileDeviceTokenAuthentication
@ -36,7 +36,7 @@ class MobileDeviceInfoSerializer(PassiveSerializer):
others = JSONField() others = JSONField()
class MobileDeviceSerializer(ModelSerializer): class MobileDeviceSerializer(DeviceSerializer):
"""Serializer for Mobile authenticator devices""" """Serializer for Mobile authenticator devices"""
last_checkin = MobileDeviceInfoSerializer(read_only=True) last_checkin = MobileDeviceInfoSerializer(read_only=True)

View File

@ -3,10 +3,10 @@ from django_filters.rest_framework.backends import DjangoFilterBackend
from rest_framework import mixins from rest_framework import mixins
from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAdminUser from rest_framework.permissions import IsAdminUser
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from authentik.api.authorization import OwnerFilter, OwnerPermissions 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.used_by import UsedByMixin
from authentik.flows.api.stages import StageSerializer from authentik.flows.api.stages import StageSerializer
from authentik.stages.authenticator_sms.models import AuthenticatorSMSStage, SMSDevice from authentik.stages.authenticator_sms.models import AuthenticatorSMSStage, SMSDevice
@ -41,7 +41,7 @@ class AuthenticatorSMSStageViewSet(UsedByMixin, ModelViewSet):
search_fields = ["name"] search_fields = ["name"]
class SMSDeviceSerializer(ModelSerializer): class SMSDeviceSerializer(DeviceSerializer):
"""Serializer for sms authenticator devices""" """Serializer for sms authenticator devices"""
class Meta: class Meta:

View File

@ -7,6 +7,7 @@ from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from authentik.api.authorization import OwnerFilter, OwnerPermissions 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.used_by import UsedByMixin
from authentik.flows.api.stages import StageSerializer from authentik.flows.api.stages import StageSerializer
from authentik.stages.authenticator_static.models import ( from authentik.stages.authenticator_static.models import (
@ -47,7 +48,7 @@ class StaticDeviceTokenSerializer(ModelSerializer):
fields = ["token"] fields = ["token"]
class StaticDeviceSerializer(ModelSerializer): class StaticDeviceSerializer(DeviceSerializer):
"""Serializer for static authenticator devices""" """Serializer for static authenticator devices"""
token_set = StaticDeviceTokenSerializer(many=True, read_only=True) token_set = StaticDeviceTokenSerializer(many=True, read_only=True)

View File

@ -4,10 +4,10 @@ from rest_framework import mixins
from rest_framework.fields import ChoiceField from rest_framework.fields import ChoiceField
from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAdminUser from rest_framework.permissions import IsAdminUser
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from authentik.api.authorization import OwnerFilter, OwnerPermissions 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.used_by import UsedByMixin
from authentik.flows.api.stages import StageSerializer from authentik.flows.api.stages import StageSerializer
from authentik.stages.authenticator_totp.models import ( from authentik.stages.authenticator_totp.models import (
@ -37,7 +37,7 @@ class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet):
search_fields = ["name"] search_fields = ["name"]
class TOTPDeviceSerializer(ModelSerializer): class TOTPDeviceSerializer(DeviceSerializer):
"""Serializer for totp authenticator devices""" """Serializer for totp authenticator devices"""
class Meta: class Meta:

View File

@ -3,10 +3,10 @@ from django_filters.rest_framework.backends import DjangoFilterBackend
from rest_framework import mixins from rest_framework import mixins
from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.permissions import IsAdminUser from rest_framework.permissions import IsAdminUser
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import GenericViewSet, ModelViewSet from rest_framework.viewsets import GenericViewSet, ModelViewSet
from authentik.api.authorization import OwnerFilter, OwnerPermissions 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.used_by import UsedByMixin
from authentik.flows.api.stages import StageSerializer from authentik.flows.api.stages import StageSerializer
from authentik.stages.authenticator_webauthn.models import AuthenticateWebAuthnStage, WebAuthnDevice from authentik.stages.authenticator_webauthn.models import AuthenticateWebAuthnStage, WebAuthnDevice
@ -36,7 +36,7 @@ class AuthenticateWebAuthnStageViewSet(UsedByMixin, ModelViewSet):
search_fields = ["name"] search_fields = ["name"]
class WebAuthnDeviceSerializer(ModelSerializer): class WebAuthnDeviceSerializer(DeviceSerializer):
"""Serializer for WebAuthn authenticator devices""" """Serializer for WebAuthn authenticator devices"""
class Meta: class Meta:

View File

@ -6031,12 +6031,15 @@
"model_authentik_stages_authenticator_duo.duodevice": { "model_authentik_stages_authenticator_duo.duodevice": {
"type": "object", "type": "object",
"properties": { "properties": {
"pk": {
"type": "string",
"minLength": 1,
"title": "Pk"
},
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 64,
"minLength": 1, "minLength": 1,
"title": "Name", "title": "Name"
"description": "The human-readable name of this device."
} }
}, },
"required": [] "required": []
@ -6166,20 +6169,13 @@
"properties": { "properties": {
"pk": { "pk": {
"type": "string", "type": "string",
"format": "uuid", "minLength": 1,
"title": "Uuid" "title": "Pk"
}, },
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 64,
"minLength": 1, "minLength": 1,
"title": "Name", "title": "Name"
"description": "The human-readable name of this device."
},
"state": {
"type": "object",
"additionalProperties": true,
"title": "State"
} }
}, },
"required": [] "required": []
@ -6338,12 +6334,15 @@
"model_authentik_stages_authenticator_sms.smsdevice": { "model_authentik_stages_authenticator_sms.smsdevice": {
"type": "object", "type": "object",
"properties": { "properties": {
"pk": {
"type": "string",
"minLength": 1,
"title": "Pk"
},
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 64,
"minLength": 1, "minLength": 1,
"title": "Name", "title": "Name"
"description": "The human-readable name of this device."
} }
}, },
"required": [] "required": []
@ -6469,12 +6468,15 @@
"model_authentik_stages_authenticator_static.staticdevice": { "model_authentik_stages_authenticator_static.staticdevice": {
"type": "object", "type": "object",
"properties": { "properties": {
"pk": {
"type": "string",
"minLength": 1,
"title": "Pk"
},
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 64,
"minLength": 1, "minLength": 1,
"title": "Name", "title": "Name"
"description": "The human-readable name of this device."
} }
}, },
"required": [] "required": []
@ -6596,12 +6598,15 @@
"model_authentik_stages_authenticator_totp.totpdevice": { "model_authentik_stages_authenticator_totp.totpdevice": {
"type": "object", "type": "object",
"properties": { "properties": {
"pk": {
"type": "string",
"minLength": 1,
"title": "Pk"
},
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 64,
"minLength": 1, "minLength": 1,
"title": "Name", "title": "Name"
"description": "The human-readable name of this device."
} }
}, },
"required": [] "required": []
@ -6889,9 +6894,13 @@
"model_authentik_stages_authenticator_webauthn.webauthndevice": { "model_authentik_stages_authenticator_webauthn.webauthndevice": {
"type": "object", "type": "object",
"properties": { "properties": {
"pk": {
"type": "string",
"minLength": 1,
"title": "Pk"
},
"name": { "name": {
"type": "string", "type": "string",
"maxLength": 200,
"minLength": 1, "minLength": 1,
"title": "Name" "title": "Name"
} }

View File

@ -31895,7 +31895,7 @@ components:
description: Return internal model name description: Return internal model name
readOnly: true readOnly: true
pk: pk:
type: integer type: string
name: name:
type: string type: string
type: type:
@ -31904,6 +31904,7 @@ components:
readOnly: true readOnly: true
confirmed: confirmed:
type: boolean type: boolean
readOnly: true
required: required:
- confirmed - confirmed
- meta_model_name - meta_model_name
@ -32229,17 +32230,37 @@ components:
type: object type: object
description: Serializer for Duo authenticator devices description: Serializer for Duo authenticator devices
properties: properties:
pk: verbose_name:
type: integer type: string
description: Return object's verbose_name
readOnly: true 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: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64 type: string
description: Get type of device
readOnly: true
confirmed:
type: boolean
readOnly: true
required: required:
- confirmed
- meta_model_name
- name - name
- pk - pk
- type
- verbose_name
- verbose_name_plural
DuoDeviceEnrollmentStatus: DuoDeviceEnrollmentStatus:
type: object type: object
properties: properties:
@ -32251,13 +32272,15 @@ components:
type: object type: object
description: Serializer for Duo authenticator devices description: Serializer for Duo authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
required: required:
- name - name
- pk
DuoResponseEnum: DuoResponseEnum:
enum: enum:
- success - success
@ -35310,24 +35333,42 @@ components:
type: object type: object
description: Serializer for Mobile authenticator devices description: Serializer for Mobile authenticator devices
properties: 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: pk:
type: string type: string
format: uuid
title: Uuid
name: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64 type: string
state: description: Get type of device
type: object readOnly: true
additionalProperties: {} confirmed:
type: boolean
readOnly: true
last_checkin: last_checkin:
allOf: allOf:
- $ref: '#/components/schemas/MobileDeviceInfo' - $ref: '#/components/schemas/MobileDeviceInfo'
readOnly: true readOnly: true
required: required:
- confirmed
- last_checkin - last_checkin
- meta_model_name
- name - name
- pk
- type
- verbose_name
- verbose_name_plural
MobileDeviceEnrollmentCallback: MobileDeviceEnrollmentCallback:
type: object type: object
properties: properties:
@ -35420,18 +35461,13 @@ components:
properties: properties:
pk: pk:
type: string type: string
format: uuid minLength: 1
title: Uuid
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
state:
type: object
additionalProperties: {}
required: required:
- name - name
- pk
MobileDeviceResponseRequest: MobileDeviceResponseRequest:
type: object type: object
description: Response from push sent to phone description: Response from push sent to phone
@ -38527,11 +38563,12 @@ components:
type: object type: object
description: Serializer for Duo authenticator devices description: Serializer for Duo authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
PatchedEmailStageRequest: PatchedEmailStageRequest:
type: object type: object
description: EmailStage Serializer description: EmailStage Serializer
@ -39291,16 +39328,10 @@ components:
properties: properties:
pk: pk:
type: string type: string
format: uuid minLength: 1
title: Uuid
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
state:
type: object
additionalProperties: {}
PatchedNotificationRequest: PatchedNotificationRequest:
type: object type: object
description: Notification Serializer description: Notification Serializer
@ -40334,11 +40365,12 @@ components:
type: object type: object
description: Serializer for sms authenticator devices description: Serializer for sms authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
PatchedScopeMappingRequest: PatchedScopeMappingRequest:
type: object type: object
description: ScopeMapping Serializer description: ScopeMapping Serializer
@ -40370,20 +40402,22 @@ components:
type: object type: object
description: Serializer for static authenticator devices description: Serializer for static authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
PatchedTOTPDeviceRequest: PatchedTOTPDeviceRequest:
type: object type: object
description: Serializer for totp authenticator devices description: Serializer for totp authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
PatchedTenantRequest: PatchedTenantRequest:
type: object type: object
description: Tenant Serializer description: Tenant Serializer
@ -40624,10 +40658,12 @@ components:
type: object type: object
description: Serializer for WebAuthn authenticator devices description: Serializer for WebAuthn authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
maxLength: 200
Permission: Permission:
type: object type: object
description: Global permission description: Global permission
@ -43312,32 +43348,50 @@ components:
type: object type: object
description: Serializer for sms authenticator devices description: Serializer for sms authenticator devices
properties: 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: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64
pk:
type: integer
readOnly: true
title: ID
phone_number:
type: string type: string
description: Get type of device
readOnly: true
confirmed:
type: boolean
readOnly: true readOnly: true
required: required:
- confirmed
- meta_model_name
- name - name
- phone_number
- pk - pk
- type
- verbose_name
- verbose_name_plural
SMSDeviceRequest: SMSDeviceRequest:
type: object type: object
description: Serializer for sms authenticator devices description: Serializer for sms authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
required: required:
- name - name
- pk
ScopeMapping: ScopeMapping:
type: object type: object
description: ScopeMapping Serializer description: ScopeMapping Serializer
@ -43835,34 +43889,56 @@ components:
type: object type: object
description: Serializer for static authenticator devices description: Serializer for static authenticator devices
properties: 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: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64 type: string
description: Get type of device
readOnly: true
confirmed:
type: boolean
readOnly: true
token_set: token_set:
type: array type: array
items: items:
$ref: '#/components/schemas/StaticDeviceToken' $ref: '#/components/schemas/StaticDeviceToken'
readOnly: true readOnly: true
pk:
type: integer
readOnly: true
title: ID
required: required:
- confirmed
- meta_model_name
- name - name
- pk - pk
- token_set - token_set
- type
- verbose_name
- verbose_name_plural
StaticDeviceRequest: StaticDeviceRequest:
type: object type: object
description: Serializer for static authenticator devices description: Serializer for static authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
required: required:
- name - name
- pk
StaticDeviceToken: StaticDeviceToken:
type: object type: object
description: Serializer for static device's tokens description: Serializer for static device's tokens
@ -43965,28 +44041,50 @@ components:
type: object type: object
description: Serializer for totp authenticator devices description: Serializer for totp authenticator devices
properties: 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: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64 type: string
pk: description: Get type of device
type: integer readOnly: true
confirmed:
type: boolean
readOnly: true readOnly: true
title: ID
required: required:
- confirmed
- meta_model_name
- name - name
- pk - pk
- type
- verbose_name
- verbose_name_plural
TOTPDeviceRequest: TOTPDeviceRequest:
type: object type: object
description: Serializer for totp authenticator devices description: Serializer for totp authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
required: required:
- name - name
- pk
Task: Task:
type: object type: object
description: Serialize TaskInfo and TaskResult description: Serialize TaskInfo and TaskResult
@ -45324,31 +45422,50 @@ components:
type: object type: object
description: Serializer for WebAuthn authenticator devices description: Serializer for WebAuthn authenticator devices
properties: properties:
pk: verbose_name:
type: integer type: string
description: Return object's verbose_name
readOnly: true 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: name:
type: string type: string
maxLength: 200 type:
created_on:
type: string type: string
format: date-time description: Get type of device
readOnly: true
confirmed:
type: boolean
readOnly: true readOnly: true
required: required:
- created_on - confirmed
- meta_model_name
- name - name
- pk - pk
- type
- verbose_name
- verbose_name_plural
WebAuthnDeviceRequest: WebAuthnDeviceRequest:
type: object type: object
description: Serializer for WebAuthn authenticator devices description: Serializer for WebAuthn authenticator devices
properties: properties:
pk:
type: string
minLength: 1
name: name:
type: string type: string
minLength: 1 minLength: 1
maxLength: 200
required: required:
- name - name
- pk
Workers: Workers:
type: object type: object
properties: properties:

View File

@ -464,24 +464,42 @@ components:
type: object type: object
description: Serializer for Mobile authenticator devices description: Serializer for Mobile authenticator devices
properties: 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: pk:
type: string type: string
format: uuid
title: Uuid
name: name:
type: string type: string
description: The human-readable name of this device. type:
maxLength: 64 type: string
state: description: Get type of device
type: object readOnly: true
additionalProperties: {} confirmed:
type: boolean
readOnly: true
last_checkin: last_checkin:
allOf: allOf:
- $ref: '#/components/schemas/MobileDeviceInfo' - $ref: '#/components/schemas/MobileDeviceInfo'
readOnly: true readOnly: true
required: required:
- confirmed
- last_checkin - last_checkin
- meta_model_name
- name - name
- pk
- type
- verbose_name
- verbose_name_plural
MobileDeviceEnrollmentCallback: MobileDeviceEnrollmentCallback:
type: object type: object
properties: properties:
@ -566,18 +584,13 @@ components:
properties: properties:
pk: pk:
type: string type: string
format: uuid minLength: 1
title: Uuid
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
state:
type: object
additionalProperties: {}
required: required:
- name - name
- pk
MobileDeviceResponseRequest: MobileDeviceResponseRequest:
type: object type: object
description: Response from push sent to phone description: Response from push sent to phone
@ -643,16 +656,10 @@ components:
properties: properties:
pk: pk:
type: string type: string
format: uuid minLength: 1
title: Uuid
name: name:
type: string type: string
minLength: 1 minLength: 1
description: The human-readable name of this device.
maxLength: 64
state:
type: object
additionalProperties: {}
PlatformEnum: PlatformEnum:
enum: enum:
- ios - ios

View File

@ -49,18 +49,21 @@ export class UserDeviceTable extends Table<Device> {
async deleteWrapper(device: Device) { async deleteWrapper(device: Device) {
const api = new AuthenticatorsApi(DEFAULT_CONFIG); const api = new AuthenticatorsApi(DEFAULT_CONFIG);
const id = { id: device.pk }; switch (device.type.toLowerCase()) {
switch (device.type) { case "authentik_stages_authenticator_duo.duodevice":
case "authentik_stages_authenticator_duo.DuoDevice": return api.authenticatorsAdminDuoDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsAdminDuoDestroy(id); case "authentik_stages_authenticator_sms.smsdevice":
case "authentik_stages_authenticator_sms.SMSDevice": return api.authenticatorsAdminSmsDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsAdminSmsDestroy(id); case "authentik_stages_authenticator_totp.totpdevice":
case "authentik_stages_authenticator_totp.TOTPDevice": return api.authenticatorsAdminTotpDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsAdminTotpDestroy(id); case "authentik_stages_authenticator_static.staticdevice":
case "authentik_stages_authenticator_static.StaticDevice": return api.authenticatorsAdminStaticDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsAdminStaticDestroy(id); case "authentik_stages_authenticator_webauthn.webauthndevice":
case "authentik_stages_authenticator_webauthn.WebAuthnDevice": return api.authenticatorsAdminWebauthnDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsAdminWebauthnDestroy(id); case "authentik_stages_authenticator_mobile.mobiledevice":
return api.authenticatorsMobileDestroy({
uuid: device.pk,
});
default: default:
break; break;
} }

View File

@ -10,11 +10,11 @@ import { ifDefined } from "lit/directives/if-defined.js";
import { AuthenticatorsApi, Device } from "@goauthentik/api"; import { AuthenticatorsApi, Device } from "@goauthentik/api";
@customElement("ak-user-mfa-form") @customElement("ak-user-mfa-form")
export class MFADeviceForm extends ModelForm<Device, number> { export class MFADeviceForm extends ModelForm<Device, string> {
@property() @property()
deviceType!: string; deviceType!: string;
async loadInstance(pk: number): Promise<Device> { async loadInstance(pk: string): Promise<Device> {
const devices = await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList(); const devices = await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList();
return devices.filter((device) => { return devices.filter((device) => {
return device.pk === pk && device.type === this.deviceType; return device.pk === pk && device.type === this.deviceType;
@ -26,37 +26,43 @@ export class MFADeviceForm extends ModelForm<Device, number> {
} }
async send(device: Device): Promise<Device> { async send(device: Device): Promise<Device> {
switch (this.instance?.type) { switch (this.instance?.type.toLowerCase()) {
case "authentik_stages_authenticator_duo.DuoDevice": case "authentik_stages_authenticator_duo.duodevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoUpdate({ await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoUpdate({
id: this.instance?.pk, id: parseInt(this.instance?.pk, 10),
duoDeviceRequest: device, duoDeviceRequest: device,
}); });
break; break;
case "authentik_stages_authenticator_sms.SMSDevice": case "authentik_stages_authenticator_sms.smsdevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsSmsUpdate({ await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsSmsUpdate({
id: this.instance?.pk, id: parseInt(this.instance?.pk, 10),
sMSDeviceRequest: device, sMSDeviceRequest: device,
}); });
break; break;
case "authentik_stages_authenticator_totp.TOTPDevice": case "authentik_stages_authenticator_totp.totpdevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsTotpUpdate({ await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsTotpUpdate({
id: this.instance?.pk, id: parseInt(this.instance?.pk, 10),
tOTPDeviceRequest: device, tOTPDeviceRequest: device,
}); });
break; break;
case "authentik_stages_authenticator_static.StaticDevice": case "authentik_stages_authenticator_static.staticdevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsStaticUpdate({ await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsStaticUpdate({
id: this.instance?.pk, id: parseInt(this.instance?.pk, 10),
staticDeviceRequest: device, staticDeviceRequest: device,
}); });
break; break;
case "authentik_stages_authenticator_webauthn.WebAuthnDevice": case "authentik_stages_authenticator_webauthn.webauthndevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsWebauthnUpdate({ await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsWebauthnUpdate({
id: this.instance?.pk, id: parseInt(this.instance?.pk, 10),
webAuthnDeviceRequest: device, webAuthnDeviceRequest: device,
}); });
break; break;
case "authentik_stages_authenticator_mobile.mobiledevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsMobileUpdate({
uuid: this.instance?.pk,
mobileDeviceRequest: device,
});
break;
default: default:
break; break;
} }

View File

@ -85,21 +85,20 @@ export class MFADevicesPage extends Table<Device> {
async deleteWrapper(device: Device) { async deleteWrapper(device: Device) {
const api = new AuthenticatorsApi(DEFAULT_CONFIG); const api = new AuthenticatorsApi(DEFAULT_CONFIG);
const id = { id: device.pk }; switch (device.type.toLowerCase()) {
switch (device.type) { case "authentik_stages_authenticator_duo.duodevice":
case "authentik_stages_authenticator_duo.DuoDevice": return api.authenticatorsDuoDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsDuoDestroy(id); case "authentik_stages_authenticator_sms.smsdevice":
case "authentik_stages_authenticator_sms.SMSDevice": return api.authenticatorsSmsDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsSmsDestroy(id); case "authentik_stages_authenticator_totp.totpdevice":
case "authentik_stages_authenticator_totp.TOTPDevice": return api.authenticatorsTotpDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsTotpDestroy(id); case "authentik_stages_authenticator_static.staticdevice":
case "authentik_stages_authenticator_static.StaticDevice": return api.authenticatorsStaticDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsStaticDestroy(id); case "authentik_stages_authenticator_webauthn.webauthndevice":
case "authentik_stages_authenticator_webauthn.WebAuthnDevice": return api.authenticatorsWebauthnDestroy({ id: parseInt(device.pk, 10) });
return api.authenticatorsWebauthnDestroy(id);
case "authentik_stages_authenticator_mobile.mobiledevice": case "authentik_stages_authenticator_mobile.mobiledevice":
return api.authenticatorsMobileDestroy({ return api.authenticatorsMobileDestroy({
uuid: device.pk as unknown as string, uuid: device.pk,
}); });
default: default:
break; break;