authentik.stages.authenticator_totp.api
AuthenticatorTOTPStage API Views
1"""AuthenticatorTOTPStage API Views""" 2 3from rest_framework import mixins 4from rest_framework.fields import ChoiceField 5from rest_framework.viewsets import GenericViewSet, ModelViewSet 6 7from authentik.core.api.groups import PartialUserSerializer 8from authentik.core.api.used_by import UsedByMixin 9from authentik.core.api.utils import ModelSerializer 10from authentik.flows.api.stages import StageSerializer 11from authentik.stages.authenticator_totp.models import ( 12 AuthenticatorTOTPStage, 13 TOTPDevice, 14 TOTPDigits, 15) 16 17 18class AuthenticatorTOTPStageSerializer(StageSerializer): 19 """AuthenticatorTOTPStage Serializer""" 20 21 digits = ChoiceField(choices=TOTPDigits.choices) 22 23 class Meta: 24 model = AuthenticatorTOTPStage 25 fields = StageSerializer.Meta.fields + ["configure_flow", "friendly_name", "digits"] 26 27 28class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet): 29 """AuthenticatorTOTPStage Viewset""" 30 31 queryset = AuthenticatorTOTPStage.objects.all() 32 serializer_class = AuthenticatorTOTPStageSerializer 33 filterset_fields = "__all__" 34 ordering = ["name"] 35 search_fields = ["name"] 36 37 38class TOTPDeviceSerializer(ModelSerializer): 39 """Serializer for totp authenticator devices""" 40 41 user = PartialUserSerializer(read_only=True) 42 43 class Meta: 44 model = TOTPDevice 45 fields = [ 46 "name", 47 "pk", 48 "user", 49 ] 50 depth = 2 51 52 53class TOTPDeviceViewSet( 54 mixins.RetrieveModelMixin, 55 mixins.UpdateModelMixin, 56 mixins.DestroyModelMixin, 57 UsedByMixin, 58 mixins.ListModelMixin, 59 GenericViewSet, 60): 61 """Viewset for totp authenticator devices""" 62 63 queryset = TOTPDevice.objects.filter(confirmed=True) 64 serializer_class = TOTPDeviceSerializer 65 search_fields = ["name"] 66 filterset_fields = ["name"] 67 ordering = ["name"] 68 owner_field = "user" 69 70 71class TOTPAdminDeviceViewSet(ModelViewSet): 72 """Viewset for totp authenticator devices (for admins)""" 73 74 queryset = TOTPDevice.objects.all() 75 serializer_class = TOTPDeviceSerializer 76 search_fields = ["name"] 77 filterset_fields = ["name"] 78 ordering = ["name"]
19class AuthenticatorTOTPStageSerializer(StageSerializer): 20 """AuthenticatorTOTPStage Serializer""" 21 22 digits = ChoiceField(choices=TOTPDigits.choices) 23 24 class Meta: 25 model = AuthenticatorTOTPStage 26 fields = StageSerializer.Meta.fields + ["configure_flow", "friendly_name", "digits"]
AuthenticatorTOTPStage Serializer
Inherited Members
class
AuthenticatorTOTPStageSerializer.Meta:
24 class Meta: 25 model = AuthenticatorTOTPStage 26 fields = StageSerializer.Meta.fields + ["configure_flow", "friendly_name", "digits"]
model =
<class 'authentik.stages.authenticator_totp.models.AuthenticatorTOTPStage'>
class
AuthenticatorTOTPStageViewSet(authentik.core.api.used_by.UsedByMixin, rest_framework.viewsets.ModelViewSet):
29class AuthenticatorTOTPStageViewSet(UsedByMixin, ModelViewSet): 30 """AuthenticatorTOTPStage Viewset""" 31 32 queryset = AuthenticatorTOTPStage.objects.all() 33 serializer_class = AuthenticatorTOTPStageSerializer 34 filterset_fields = "__all__" 35 ordering = ["name"] 36 search_fields = ["name"]
AuthenticatorTOTPStage Viewset
serializer_class =
<class 'AuthenticatorTOTPStageSerializer'>
Inherited Members
39class TOTPDeviceSerializer(ModelSerializer): 40 """Serializer for totp authenticator devices""" 41 42 user = PartialUserSerializer(read_only=True) 43 44 class Meta: 45 model = TOTPDevice 46 fields = [ 47 "name", 48 "pk", 49 "user", 50 ] 51 depth = 2
Serializer for totp authenticator devices
Inherited Members
class
TOTPDeviceSerializer.Meta:
model =
<class 'authentik.stages.authenticator_totp.models.TOTPDevice'>
class
TOTPDeviceViewSet(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):
54class TOTPDeviceViewSet( 55 mixins.RetrieveModelMixin, 56 mixins.UpdateModelMixin, 57 mixins.DestroyModelMixin, 58 UsedByMixin, 59 mixins.ListModelMixin, 60 GenericViewSet, 61): 62 """Viewset for totp authenticator devices""" 63 64 queryset = TOTPDevice.objects.filter(confirmed=True) 65 serializer_class = TOTPDeviceSerializer 66 search_fields = ["name"] 67 filterset_fields = ["name"] 68 ordering = ["name"] 69 owner_field = "user"
Viewset for totp authenticator devices
serializer_class =
<class 'TOTPDeviceSerializer'>
Inherited Members
class
TOTPAdminDeviceViewSet(rest_framework.viewsets.ModelViewSet):
72class TOTPAdminDeviceViewSet(ModelViewSet): 73 """Viewset for totp authenticator devices (for admins)""" 74 75 queryset = TOTPDevice.objects.all() 76 serializer_class = TOTPDeviceSerializer 77 search_fields = ["name"] 78 filterset_fields = ["name"] 79 ordering = ["name"]
Viewset for totp authenticator devices (for admins)
serializer_class =
<class 'TOTPDeviceSerializer'>