2020-02-19 18:53:43 +00:00
|
|
|
# Copyright © 2017 Tom Hacohen
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, version 3.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import base64
|
|
|
|
|
2020-04-15 13:53:31 +00:00
|
|
|
from django.core.files.base import ContentFile
|
2020-02-19 18:53:43 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
2020-02-26 13:53:25 +00:00
|
|
|
from django.db import transaction
|
2020-02-19 18:53:43 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
|
2020-04-15 13:59:30 +00:00
|
|
|
def process_revisions_for_item(item, revision_data):
|
2020-04-15 14:35:51 +00:00
|
|
|
chunks_objs = []
|
|
|
|
chunks = revision_data.pop('chunks_relation')
|
2020-04-15 13:59:30 +00:00
|
|
|
for chunk in chunks:
|
|
|
|
uid = chunk[0]
|
|
|
|
if len(chunk) > 1:
|
|
|
|
content = chunk[1]
|
2020-04-15 14:35:51 +00:00
|
|
|
chunk = models.CollectionItemChunk(uid=uid, item=item)
|
2020-04-15 13:59:30 +00:00
|
|
|
chunk.chunkFile.save('IGNORED', ContentFile(content))
|
|
|
|
chunk.save()
|
2020-04-15 14:35:51 +00:00
|
|
|
chunks_objs.append(chunk)
|
2020-04-15 13:59:30 +00:00
|
|
|
else:
|
|
|
|
chunk = models.CollectionItemChunk.objects.get(uid=uid)
|
2020-04-15 14:35:51 +00:00
|
|
|
chunks_objs.append(chunk)
|
2020-04-15 13:59:30 +00:00
|
|
|
|
2020-05-26 15:52:44 +00:00
|
|
|
stoken = models.Stoken.objects.create()
|
|
|
|
|
|
|
|
revision = models.CollectionItemRevision.objects.create(**revision_data, item=item, stoken=stoken)
|
2020-04-15 14:35:51 +00:00
|
|
|
for chunk in chunks_objs:
|
|
|
|
models.RevisionChunkRelation.objects.create(chunk=chunk, revision=revision)
|
2020-04-15 13:59:30 +00:00
|
|
|
return revision
|
|
|
|
|
|
|
|
|
2020-04-15 11:33:38 +00:00
|
|
|
def b64encode(value):
|
2020-04-15 13:50:47 +00:00
|
|
|
return base64.urlsafe_b64encode(value).decode('ascii').strip('=')
|
2020-04-15 11:33:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
def b64decode(data):
|
|
|
|
data += "=" * ((4 - len(data) % 4) % 4)
|
|
|
|
return base64.urlsafe_b64decode(data)
|
|
|
|
|
|
|
|
|
2020-02-19 18:53:43 +00:00
|
|
|
class BinaryBase64Field(serializers.Field):
|
|
|
|
def to_representation(self, value):
|
2020-04-15 11:33:38 +00:00
|
|
|
return b64encode(value)
|
2020-02-19 18:53:43 +00:00
|
|
|
|
|
|
|
def to_internal_value(self, data):
|
2020-04-15 11:33:38 +00:00
|
|
|
return b64decode(data)
|
2020-02-19 18:53:43 +00:00
|
|
|
|
|
|
|
|
2020-02-26 18:54:00 +00:00
|
|
|
class CollectionEncryptionKeyField(BinaryBase64Field):
|
|
|
|
def get_attribute(self, instance):
|
|
|
|
request = self.context.get('request', None)
|
|
|
|
if request is not None:
|
|
|
|
return instance.members.get(user=request.user).encryptionKey
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2020-03-12 19:02:27 +00:00
|
|
|
class CollectionContentField(BinaryBase64Field):
|
|
|
|
def get_attribute(self, instance):
|
2020-02-19 18:53:43 +00:00
|
|
|
request = self.context.get('request', None)
|
|
|
|
if request is not None:
|
2020-03-12 19:02:27 +00:00
|
|
|
return instance.members.get(user=request.user).encryptionKey
|
2020-02-26 18:38:07 +00:00
|
|
|
return None
|
2020-02-19 18:53:43 +00:00
|
|
|
|
|
|
|
|
2020-04-15 13:27:03 +00:00
|
|
|
class ChunksField(serializers.RelatedField):
|
|
|
|
def to_representation(self, obj):
|
2020-04-15 14:35:51 +00:00
|
|
|
obj = obj.chunk
|
2020-04-15 13:47:31 +00:00
|
|
|
inline = self.context.get('inline', False)
|
|
|
|
if inline:
|
2020-04-15 13:27:03 +00:00
|
|
|
with open(obj.chunkFile.path, 'rb') as f:
|
|
|
|
return (obj.uid, b64encode(f.read()))
|
|
|
|
else:
|
|
|
|
return (obj.uid, )
|
|
|
|
|
|
|
|
def to_internal_value(self, data):
|
|
|
|
return (data[0], b64decode(data[1]))
|
|
|
|
|
|
|
|
|
2020-02-19 18:53:43 +00:00
|
|
|
class CollectionItemChunkSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionItemChunk
|
2020-02-20 12:42:35 +00:00
|
|
|
fields = ('uid', 'chunkFile')
|
2020-02-19 18:53:43 +00:00
|
|
|
|
|
|
|
|
2020-04-15 12:23:07 +00:00
|
|
|
class CollectionItemRevisionSerializer(serializers.ModelSerializer):
|
2020-04-15 13:27:03 +00:00
|
|
|
chunks = ChunksField(
|
2020-04-15 14:35:51 +00:00
|
|
|
source='chunks_relation',
|
|
|
|
queryset=models.RevisionChunkRelation.objects.all(),
|
2020-02-19 18:53:43 +00:00
|
|
|
many=True
|
|
|
|
)
|
2020-04-14 15:30:07 +00:00
|
|
|
meta = BinaryBase64Field()
|
2020-02-19 18:53:43 +00:00
|
|
|
|
|
|
|
class Meta:
|
2020-02-20 20:41:39 +00:00
|
|
|
model = models.CollectionItemRevision
|
2020-04-15 13:27:03 +00:00
|
|
|
fields = ('chunks', 'meta', 'uid', 'deleted')
|
2020-04-15 12:23:07 +00:00
|
|
|
|
2020-02-26 12:21:14 +00:00
|
|
|
|
2020-02-20 11:56:16 +00:00
|
|
|
class CollectionItemSerializer(serializers.ModelSerializer):
|
2020-03-10 15:49:23 +00:00
|
|
|
encryptionKey = BinaryBase64Field()
|
2020-05-27 07:16:55 +00:00
|
|
|
etag = serializers.CharField(allow_null=True, write_only=True)
|
2020-02-26 13:53:25 +00:00
|
|
|
content = CollectionItemRevisionSerializer(many=False)
|
2020-02-20 11:56:16 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionItem
|
2020-05-27 07:09:45 +00:00
|
|
|
fields = ('uid', 'version', 'encryptionKey', 'content', 'etag')
|
2020-02-20 11:56:16 +00:00
|
|
|
|
2020-02-26 14:07:55 +00:00
|
|
|
def create(self, validated_data):
|
|
|
|
"""Function that's called when this serializer creates an item"""
|
2020-05-27 07:09:45 +00:00
|
|
|
validate_etag = self.context.get('validate_etag', False)
|
|
|
|
etag = validated_data.pop('etag')
|
2020-02-26 14:07:55 +00:00
|
|
|
revision_data = validated_data.pop('content')
|
2020-05-19 10:00:54 +00:00
|
|
|
uid = validated_data.pop('uid')
|
|
|
|
|
|
|
|
Model = self.__class__.Meta.model
|
2020-02-26 14:07:55 +00:00
|
|
|
|
|
|
|
with transaction.atomic():
|
2020-05-19 10:00:54 +00:00
|
|
|
instance, created = Model.objects.get_or_create(uid=uid, defaults=validated_data)
|
2020-05-27 07:09:45 +00:00
|
|
|
cur_etag = instance.etag if not created else None
|
2020-05-19 10:00:54 +00:00
|
|
|
|
2020-05-27 07:09:45 +00:00
|
|
|
if validate_etag and cur_etag != etag:
|
|
|
|
raise serializers.ValidationError('Wrong etag. Expected {} got {}'.format(cur_etag, etag))
|
2020-05-19 07:48:39 +00:00
|
|
|
|
2020-05-19 10:00:54 +00:00
|
|
|
if not created:
|
|
|
|
# We don't have to use select_for_update here because the unique constraint on current guards against
|
|
|
|
# the race condition. But it's a good idea because it'll lock and wait rather than fail.
|
|
|
|
current_revision = instance.revisions.filter(current=True).select_for_update().first()
|
|
|
|
current_revision.current = None
|
|
|
|
current_revision.save()
|
2020-02-26 14:07:55 +00:00
|
|
|
|
2020-04-15 13:59:30 +00:00
|
|
|
process_revisions_for_item(instance, revision_data)
|
2020-02-26 14:07:55 +00:00
|
|
|
|
|
|
|
return instance
|
|
|
|
|
2020-02-26 13:53:25 +00:00
|
|
|
def update(self, instance, validated_data):
|
2020-05-19 10:00:54 +00:00
|
|
|
# We never update, we always update in the create method
|
|
|
|
raise NotImplementedError()
|
2020-02-26 13:53:25 +00:00
|
|
|
|
2020-02-20 11:56:16 +00:00
|
|
|
|
2020-05-19 08:20:02 +00:00
|
|
|
class CollectionItemDepSerializer(serializers.ModelSerializer):
|
2020-05-27 07:09:45 +00:00
|
|
|
etag = serializers.CharField()
|
2020-05-19 08:20:02 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionItem
|
2020-05-27 07:09:45 +00:00
|
|
|
fields = ('uid', 'etag')
|
2020-05-19 08:20:02 +00:00
|
|
|
|
|
|
|
def validate(self, data):
|
2020-05-19 08:44:20 +00:00
|
|
|
item = self.__class__.Meta.model.objects.get(uid=data['uid'])
|
2020-05-27 07:09:45 +00:00
|
|
|
etag = data['etag']
|
|
|
|
if item.etag != etag:
|
|
|
|
raise serializers.ValidationError('Wrong etag. Expected {} got {}'.format(item.etag, etag))
|
2020-05-19 08:20:02 +00:00
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
2020-05-19 14:57:51 +00:00
|
|
|
class CollectionItemBulkGetSerializer(serializers.ModelSerializer):
|
2020-05-27 07:09:45 +00:00
|
|
|
etag = serializers.CharField(required=False)
|
2020-05-19 14:57:51 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionItem
|
2020-05-27 07:09:45 +00:00
|
|
|
fields = ('uid', 'etag')
|
2020-05-19 14:57:51 +00:00
|
|
|
|
|
|
|
|
2020-03-12 19:02:27 +00:00
|
|
|
class CollectionSerializer(serializers.ModelSerializer):
|
|
|
|
encryptionKey = CollectionEncryptionKeyField()
|
|
|
|
accessLevel = serializers.SerializerMethodField('get_access_level_from_context')
|
2020-05-27 07:09:45 +00:00
|
|
|
stoken = serializers.CharField(read_only=True)
|
2020-05-27 07:16:55 +00:00
|
|
|
etag = serializers.CharField(allow_null=True, write_only=True)
|
2020-03-12 19:02:27 +00:00
|
|
|
content = CollectionItemRevisionSerializer(many=False)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.Collection
|
2020-05-27 07:09:45 +00:00
|
|
|
fields = ('uid', 'version', 'accessLevel', 'encryptionKey', 'content', 'stoken', 'etag')
|
2020-03-12 19:02:27 +00:00
|
|
|
|
|
|
|
def get_access_level_from_context(self, obj):
|
|
|
|
request = self.context.get('request', None)
|
|
|
|
if request is not None:
|
|
|
|
return obj.members.get(user=request.user).accessLevel
|
|
|
|
return None
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
"""Function that's called when this serializer creates an item"""
|
2020-05-27 07:09:45 +00:00
|
|
|
etag = validated_data.pop('etag')
|
2020-03-12 19:02:27 +00:00
|
|
|
revision_data = validated_data.pop('content')
|
|
|
|
encryption_key = validated_data.pop('encryptionKey')
|
|
|
|
instance = self.__class__.Meta.model(**validated_data)
|
|
|
|
|
|
|
|
with transaction.atomic():
|
2020-05-27 07:09:45 +00:00
|
|
|
if etag is not None:
|
2020-05-19 07:48:39 +00:00
|
|
|
raise serializers.ValidationError('Stoken is not None')
|
|
|
|
|
2020-04-15 13:53:31 +00:00
|
|
|
instance.save()
|
2020-03-12 19:02:27 +00:00
|
|
|
main_item = models.CollectionItem.objects.create(
|
|
|
|
uid=None, encryptionKey=None, version=instance.version, collection=instance)
|
|
|
|
|
2020-04-15 13:59:30 +00:00
|
|
|
process_revisions_for_item(main_item, revision_data)
|
2020-03-12 19:02:27 +00:00
|
|
|
|
|
|
|
models.CollectionMember(collection=instance,
|
|
|
|
user=validated_data.get('owner'),
|
2020-05-20 10:48:46 +00:00
|
|
|
accessLevel=models.AccessLevels.ADMIN,
|
2020-03-12 19:02:27 +00:00
|
|
|
encryptionKey=encryption_key,
|
|
|
|
).save()
|
|
|
|
|
|
|
|
return instance
|
2020-04-15 14:54:39 +00:00
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
"""Function that's called when this serializer is meant to update an item"""
|
2020-05-27 07:09:45 +00:00
|
|
|
etag = validated_data.pop('etag')
|
2020-04-15 14:54:39 +00:00
|
|
|
revision_data = validated_data.pop('content')
|
|
|
|
|
|
|
|
with transaction.atomic():
|
2020-05-27 07:09:45 +00:00
|
|
|
if etag != instance.etag:
|
|
|
|
raise serializers.ValidationError('Wrong etag. Expected {} got {}'.format(instance.etag, etag))
|
2020-05-19 07:48:39 +00:00
|
|
|
|
2020-04-16 08:28:49 +00:00
|
|
|
main_item = instance.main_item
|
2020-04-15 14:54:39 +00:00
|
|
|
# We don't have to use select_for_update here because the unique constraint on current guards against
|
|
|
|
# the race condition. But it's a good idea because it'll lock and wait rather than fail.
|
|
|
|
current_revision = main_item.revisions.filter(current=True).select_for_update().first()
|
|
|
|
current_revision.current = None
|
|
|
|
current_revision.save()
|
|
|
|
|
|
|
|
process_revisions_for_item(main_item, revision_data)
|
|
|
|
|
|
|
|
return instance
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
|
2020-05-20 10:48:46 +00:00
|
|
|
class CollectionMemberSerializer(serializers.ModelSerializer):
|
|
|
|
username = serializers.SlugRelatedField(
|
|
|
|
source='user',
|
|
|
|
slug_field=User.USERNAME_FIELD,
|
|
|
|
queryset=User.objects
|
|
|
|
)
|
|
|
|
encryptionKey = BinaryBase64Field()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionMember
|
|
|
|
fields = ('username', 'encryptionKey', 'accessLevel')
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
with transaction.atomic():
|
|
|
|
# We only allow updating accessLevel
|
|
|
|
instance.accessLevel = validated_data.pop('accessLevel')
|
|
|
|
instance.save()
|
|
|
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
|
2020-05-20 11:30:09 +00:00
|
|
|
class CollectionInvitationSerializer(serializers.ModelSerializer):
|
|
|
|
username = serializers.SlugRelatedField(
|
|
|
|
source='user',
|
|
|
|
slug_field=User.USERNAME_FIELD,
|
|
|
|
queryset=User.objects
|
|
|
|
)
|
2020-05-24 15:19:22 +00:00
|
|
|
collection = serializers.CharField(source='collection.uid')
|
|
|
|
fromPubkey = BinaryBase64Field(source='fromMember.user.userinfo.pubkey', read_only=True)
|
2020-05-20 11:30:09 +00:00
|
|
|
signedEncryptionKey = BinaryBase64Field()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.CollectionInvitation
|
|
|
|
fields = ('username', 'uid', 'collection', 'signedEncryptionKey', 'accessLevel', 'fromPubkey', 'version')
|
|
|
|
|
2020-05-24 14:52:09 +00:00
|
|
|
def validate_user(self, value):
|
2020-05-20 11:30:09 +00:00
|
|
|
request = self.context['request']
|
|
|
|
|
2020-05-24 15:19:22 +00:00
|
|
|
if request.user == value.lower():
|
2020-05-20 11:30:09 +00:00
|
|
|
raise serializers.ValidationError('Inviting yourself is not allowed')
|
2020-05-24 15:19:22 +00:00
|
|
|
return value
|
2020-05-20 11:30:09 +00:00
|
|
|
|
2020-05-24 14:52:09 +00:00
|
|
|
def create(self, validated_data):
|
|
|
|
request = self.context['request']
|
2020-05-24 15:19:22 +00:00
|
|
|
collection = validated_data.pop('collection')
|
2020-05-24 14:52:09 +00:00
|
|
|
|
2020-05-20 11:30:09 +00:00
|
|
|
member = collection.members.get(user=request.user)
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
return type(self).Meta.model.objects.create(**validated_data, fromMember=member)
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
with transaction.atomic():
|
|
|
|
instance.accessLevel = validated_data.pop('accessLevel')
|
|
|
|
instance.signedEncryptionKey = validated_data.pop('signedEncryptionKey')
|
|
|
|
instance.save()
|
|
|
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
|
2020-05-20 12:15:24 +00:00
|
|
|
class InvitationAcceptSerializer(serializers.Serializer):
|
|
|
|
encryptionKey = BinaryBase64Field()
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
invitation = self.context['invitation']
|
|
|
|
encryption_key = validated_data.get('encryptionKey')
|
|
|
|
|
|
|
|
member = models.CollectionMember.objects.create(
|
2020-05-24 14:22:43 +00:00
|
|
|
collection=invitation.collection,
|
|
|
|
user=invitation.user,
|
|
|
|
accessLevel=invitation.accessLevel,
|
|
|
|
encryptionKey=encryption_key,
|
|
|
|
)
|
2020-05-20 12:15:24 +00:00
|
|
|
|
|
|
|
invitation.delete()
|
|
|
|
|
|
|
|
return member
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2020-05-14 10:43:49 +00:00
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
2020-05-26 10:44:40 +00:00
|
|
|
pubkey = BinaryBase64Field(source='userinfo.pubkey')
|
|
|
|
encryptedSeckey = BinaryBase64Field(source='userinfo.encryptedSeckey')
|
|
|
|
|
2020-05-14 10:43:49 +00:00
|
|
|
class Meta:
|
|
|
|
model = User
|
2020-05-26 10:44:40 +00:00
|
|
|
fields = (User.USERNAME_FIELD, User.EMAIL_FIELD, 'pubkey', 'encryptedSeckey')
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
|
2020-05-14 14:19:18 +00:00
|
|
|
class UserQuerySerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = (User.USERNAME_FIELD, User.EMAIL_FIELD)
|
|
|
|
|
|
|
|
|
2020-05-24 12:20:55 +00:00
|
|
|
class UserInfoPubkeySerializer(serializers.ModelSerializer):
|
|
|
|
pubkey = BinaryBase64Field()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.UserInfo
|
|
|
|
fields = ('pubkey', )
|
|
|
|
|
|
|
|
|
2020-05-14 10:43:49 +00:00
|
|
|
class AuthenticationSignupSerializer(serializers.Serializer):
|
2020-05-14 14:19:18 +00:00
|
|
|
user = UserQuerySerializer(many=False)
|
2020-05-14 10:43:49 +00:00
|
|
|
salt = BinaryBase64Field()
|
2020-05-26 10:23:45 +00:00
|
|
|
loginPubkey = BinaryBase64Field()
|
2020-05-26 10:44:40 +00:00
|
|
|
pubkey = BinaryBase64Field()
|
|
|
|
encryptedSeckey = BinaryBase64Field()
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
"""Function that's called when this serializer creates an item"""
|
2020-05-18 13:13:48 +00:00
|
|
|
user_data = validated_data.pop('user')
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
with transaction.atomic():
|
2020-05-26 10:17:35 +00:00
|
|
|
instance, _ = User.objects.get_or_create(**user_data)
|
2020-05-18 13:13:48 +00:00
|
|
|
if hasattr(instance, 'userinfo'):
|
|
|
|
raise serializers.ValidationError('User already exists')
|
|
|
|
|
2020-05-14 10:43:49 +00:00
|
|
|
instance.set_unusable_password()
|
2020-05-18 13:13:48 +00:00
|
|
|
# FIXME: send email verification
|
2020-05-14 10:43:49 +00:00
|
|
|
|
2020-05-26 10:23:45 +00:00
|
|
|
models.UserInfo.objects.create(**validated_data, owner=instance)
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
return instance
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
|
|
class AuthenticationLoginChallengeSerializer(serializers.Serializer):
|
|
|
|
username = serializers.CharField(required=False)
|
|
|
|
email = serializers.EmailField(required=False)
|
|
|
|
|
|
|
|
def validate(self, data):
|
|
|
|
if not data.get('email') and not data.get('username'):
|
|
|
|
raise serializers.ValidationError('Either email or username must be set')
|
|
|
|
return data
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
2020-05-14 12:42:42 +00:00
|
|
|
class AuthenticationLoginSerializer(serializers.Serializer):
|
|
|
|
response = BinaryBase64Field()
|
2020-05-14 10:43:49 +00:00
|
|
|
signature = BinaryBase64Field()
|
|
|
|
|
2020-05-14 12:42:42 +00:00
|
|
|
def create(self, validated_data):
|
|
|
|
raise NotImplementedError()
|
2020-05-14 10:43:49 +00:00
|
|
|
|
2020-05-14 12:42:42 +00:00
|
|
|
def update(self, instance, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
|
|
class AuthenticationLoginInnerSerializer(AuthenticationLoginChallengeSerializer):
|
|
|
|
challenge = BinaryBase64Field()
|
|
|
|
host = serializers.CharField()
|
2020-05-14 10:43:49 +00:00
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
def update(self, instance, validated_data):
|
|
|
|
raise NotImplementedError()
|