1
0
mirror of https://github.com/etesync/server synced 2024-11-26 02:38:15 +00:00

Serializers: handle our variant of b64 (no padding, urlsafe).

This commit is contained in:
Tom Hacohen 2020-04-14 18:29:56 +03:00
parent 9b13404ce7
commit cf06534d6d

View File

@ -29,10 +29,11 @@ def generate_rev_uid(length=32):
class BinaryBase64Field(serializers.Field): class BinaryBase64Field(serializers.Field):
def to_representation(self, value): def to_representation(self, value):
return base64.b64encode(value).decode('ascii') return base64.urlsafe_b64encode(value).decode('ascii')
def to_internal_value(self, data): def to_internal_value(self, data):
return base64.b64decode(data) data += "=" * ((4 - len(data) % 4) % 4)
return base64.urlsafe_b64decode(data)
class CollectionEncryptionKeyField(BinaryBase64Field): class CollectionEncryptionKeyField(BinaryBase64Field):