diff --git a/authentik/stages/authenticator_static/api.py b/authentik/stages/authenticator_static/api.py index 2bbaf04a5..340d2b4df 100644 --- a/authentik/stages/authenticator_static/api.py +++ b/authentik/stages/authenticator_static/api.py @@ -1,6 +1,6 @@ """AuthenticatorStaticStage API Views""" from django_filters.rest_framework import DjangoFilterBackend -from django_otp.plugins.otp_static.models import StaticDevice +from django_otp.plugins.otp_static.models import StaticDevice, StaticToken from guardian.utils import get_anonymous_user from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.permissions import IsAdminUser @@ -27,9 +27,20 @@ class AuthenticatorStaticStageViewSet(ModelViewSet): serializer_class = AuthenticatorStaticStageSerializer +class StaticDeviceTokenSerializer(ModelSerializer): + """Serializer for static device's tokens""" + + class Meta: + + model = StaticToken + fields = ["token"] + + class StaticDeviceSerializer(ModelSerializer): """Serializer for static authenticator devices""" + token_set = StaticDeviceTokenSerializer(many=True, read_only=True) + class Meta: model = StaticDevice diff --git a/schema.yml b/schema.yml index de394e77b..7bb89544f 100644 --- a/schema.yml +++ b/schema.yml @@ -19853,10 +19853,6 @@ components: type: string description: The human-readable name of this device. maxLength: 64 - token_set: - type: array - items: - type: integer PatchedTOTPDeviceRequest: type: object description: Serializer for totp authenticator devices @@ -21570,7 +21566,8 @@ components: token_set: type: array items: - type: integer + $ref: '#/components/schemas/StaticDeviceToken' + readOnly: true pk: type: integer readOnly: true @@ -21587,13 +21584,26 @@ components: type: string description: The human-readable name of this device. maxLength: 64 - token_set: - type: array - items: - type: integer required: - name - - token_set + StaticDeviceToken: + type: object + description: Serializer for static device's tokens + properties: + token: + type: string + maxLength: 16 + required: + - token + StaticDeviceTokenRequest: + type: object + description: Serializer for static device's tokens + properties: + token: + type: string + maxLength: 16 + required: + - token StatusEnum: enum: - SUCCESSFUL