authentik.stages.authenticator_webauthn.api.devices

AuthenticatorWebAuthnStage API Views

 1"""AuthenticatorWebAuthnStage API Views"""
 2
 3from rest_framework import mixins
 4from rest_framework.viewsets import GenericViewSet, ModelViewSet
 5
 6from authentik.core.api.groups import PartialUserSerializer
 7from authentik.core.api.used_by import UsedByMixin
 8from authentik.core.api.utils import ModelSerializer
 9from authentik.stages.authenticator_webauthn.api.device_types import WebAuthnDeviceTypeSerializer
10from authentik.stages.authenticator_webauthn.models import WebAuthnDevice
11
12
13class WebAuthnDeviceSerializer(ModelSerializer):
14    """Serializer for WebAuthn authenticator devices"""
15
16    device_type = WebAuthnDeviceTypeSerializer(read_only=True, allow_null=True)
17    user = PartialUserSerializer(read_only=True)
18
19    class Meta:
20        model = WebAuthnDevice
21        fields = ["pk", "name", "created_on", "device_type", "aaguid", "user"]
22        extra_kwargs = {
23            "aaguid": {"read_only": True},
24        }
25
26
27class WebAuthnDeviceViewSet(
28    mixins.RetrieveModelMixin,
29    mixins.UpdateModelMixin,
30    mixins.DestroyModelMixin,
31    UsedByMixin,
32    mixins.ListModelMixin,
33    GenericViewSet,
34):
35    """Viewset for WebAuthn authenticator devices"""
36
37    queryset = WebAuthnDevice.objects.all()
38    serializer_class = WebAuthnDeviceSerializer
39    search_fields = ["name"]
40    filterset_fields = ["name"]
41    ordering = ["name"]
42    owner_field = "user"
43
44
45class WebAuthnAdminDeviceViewSet(ModelViewSet):
46    """Viewset for WebAuthn authenticator devices (for admins)"""
47
48    queryset = WebAuthnDevice.objects.all()
49    serializer_class = WebAuthnDeviceSerializer
50    search_fields = ["name"]
51    filterset_fields = ["name"]
52    ordering = ["name"]
class WebAuthnDeviceSerializer(authentik.core.api.utils.ModelSerializer):
14class WebAuthnDeviceSerializer(ModelSerializer):
15    """Serializer for WebAuthn authenticator devices"""
16
17    device_type = WebAuthnDeviceTypeSerializer(read_only=True, allow_null=True)
18    user = PartialUserSerializer(read_only=True)
19
20    class Meta:
21        model = WebAuthnDevice
22        fields = ["pk", "name", "created_on", "device_type", "aaguid", "user"]
23        extra_kwargs = {
24            "aaguid": {"read_only": True},
25        }

Serializer for WebAuthn authenticator devices

device_type
user
class WebAuthnDeviceSerializer.Meta:
20    class Meta:
21        model = WebAuthnDevice
22        fields = ["pk", "name", "created_on", "device_type", "aaguid", "user"]
23        extra_kwargs = {
24            "aaguid": {"read_only": True},
25        }
fields = ['pk', 'name', 'created_on', 'device_type', 'aaguid', 'user']
extra_kwargs = {'aaguid': {'read_only': True}}
class WebAuthnDeviceViewSet(rest_framework.mixins.RetrieveModelMixin, rest_framework.mixins.UpdateModelMixin, rest_framework.mixins.DestroyModelMixin, authentik.core.api.used_by.UsedByMixin, rest_framework.mixins.ListModelMixin, rest_framework.viewsets.GenericViewSet):
28class WebAuthnDeviceViewSet(
29    mixins.RetrieveModelMixin,
30    mixins.UpdateModelMixin,
31    mixins.DestroyModelMixin,
32    UsedByMixin,
33    mixins.ListModelMixin,
34    GenericViewSet,
35):
36    """Viewset for WebAuthn authenticator devices"""
37
38    queryset = WebAuthnDevice.objects.all()
39    serializer_class = WebAuthnDeviceSerializer
40    search_fields = ["name"]
41    filterset_fields = ["name"]
42    ordering = ["name"]
43    owner_field = "user"

Viewset for WebAuthn authenticator devices

queryset = <QuerySet []>
serializer_class = <class 'WebAuthnDeviceSerializer'>
search_fields = ['name']
filterset_fields = ['name']
ordering = ['name']
owner_field = 'user'
name = None
description = None
suffix = None
detail = None
basename = None
class WebAuthnAdminDeviceViewSet(rest_framework.viewsets.ModelViewSet):
46class WebAuthnAdminDeviceViewSet(ModelViewSet):
47    """Viewset for WebAuthn authenticator devices (for admins)"""
48
49    queryset = WebAuthnDevice.objects.all()
50    serializer_class = WebAuthnDeviceSerializer
51    search_fields = ["name"]
52    filterset_fields = ["name"]
53    ordering = ["name"]

Viewset for WebAuthn authenticator devices (for admins)

queryset = <QuerySet []>
serializer_class = <class 'WebAuthnDeviceSerializer'>
search_fields = ['name']
filterset_fields = ['name']
ordering = ['name']
name = None
description = None
suffix = None
detail = None
basename = None