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"""
|
"""AuthenticatorStaticStage API Views"""
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
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 guardian.utils import get_anonymous_user
|
||||||
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
|
||||||
|
@ -27,9 +27,20 @@ class AuthenticatorStaticStageViewSet(ModelViewSet):
|
||||||
serializer_class = AuthenticatorStaticStageSerializer
|
serializer_class = AuthenticatorStaticStageSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class StaticDeviceTokenSerializer(ModelSerializer):
|
||||||
|
"""Serializer for static device's tokens"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = StaticToken
|
||||||
|
fields = ["token"]
|
||||||
|
|
||||||
|
|
||||||
class StaticDeviceSerializer(ModelSerializer):
|
class StaticDeviceSerializer(ModelSerializer):
|
||||||
"""Serializer for static authenticator devices"""
|
"""Serializer for static authenticator devices"""
|
||||||
|
|
||||||
|
token_set = StaticDeviceTokenSerializer(many=True, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = StaticDevice
|
model = StaticDevice
|
||||||
|
|
30
schema.yml
30
schema.yml
|
@ -19853,10 +19853,6 @@ components:
|
||||||
type: string
|
type: string
|
||||||
description: The human-readable name of this device.
|
description: The human-readable name of this device.
|
||||||
maxLength: 64
|
maxLength: 64
|
||||||
token_set:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: integer
|
|
||||||
PatchedTOTPDeviceRequest:
|
PatchedTOTPDeviceRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Serializer for totp authenticator devices
|
description: Serializer for totp authenticator devices
|
||||||
|
@ -21570,7 +21566,8 @@ components:
|
||||||
token_set:
|
token_set:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: integer
|
$ref: '#/components/schemas/StaticDeviceToken'
|
||||||
|
readOnly: true
|
||||||
pk:
|
pk:
|
||||||
type: integer
|
type: integer
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
@ -21587,13 +21584,26 @@ components:
|
||||||
type: string
|
type: string
|
||||||
description: The human-readable name of this device.
|
description: The human-readable name of this device.
|
||||||
maxLength: 64
|
maxLength: 64
|
||||||
token_set:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: integer
|
|
||||||
required:
|
required:
|
||||||
- name
|
- 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:
|
StatusEnum:
|
||||||
enum:
|
enum:
|
||||||
- SUCCESSFUL
|
- SUCCESSFUL
|
||||||
|
|
Reference in New Issue