stages/authenticator_static: add serializer for tokens
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ec8490e105
commit
41f6d3b6e7
|
@ -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
|
||||
|
|
30
schema.yml
30
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
|
||||
|
|
Reference in New Issue