Rename pubkey to loginPubkey because we'll soon have another pubkey.

This breaks sharing because we no longer have a normal pubkey.
This will be fixed in the next commit.
This commit is contained in:
Tom Hacohen 2020-05-26 13:23:45 +03:00
parent 2412c295de
commit 863c405802
4 changed files with 22 additions and 6 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.3 on 2020-05-26 10:21
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('django_etesync', '0004_collectioninvitation_version'),
]
operations = [
migrations.RenameField(
model_name='userinfo',
old_name='pubkey',
new_name='loginPubkey',
),
]

View File

@ -174,7 +174,7 @@ class CollectionInvitation(models.Model):
class UserInfo(models.Model):
owner = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, primary_key=True)
version = models.PositiveSmallIntegerField(default=1)
pubkey = models.BinaryField(editable=True, blank=False, null=False)
loginPubkey = models.BinaryField(editable=True, blank=False, null=False)
salt = models.BinaryField(editable=True, blank=False, null=False)
def __str__(self):

View File

@ -348,13 +348,11 @@ class UserInfoPubkeySerializer(serializers.ModelSerializer):
class AuthenticationSignupSerializer(serializers.Serializer):
user = UserQuerySerializer(many=False)
salt = BinaryBase64Field()
pubkey = BinaryBase64Field()
loginPubkey = BinaryBase64Field()
def create(self, validated_data):
"""Function that's called when this serializer creates an item"""
user_data = validated_data.pop('user')
salt = validated_data.pop('salt')
pubkey = validated_data.pop('pubkey')
with transaction.atomic():
instance, _ = User.objects.get_or_create(**user_data)
@ -364,7 +362,7 @@ class AuthenticationSignupSerializer(serializers.Serializer):
instance.set_unusable_password()
# FIXME: send email verification
models.UserInfo.objects.create(salt=salt, pubkey=pubkey, owner=instance)
models.UserInfo.objects.create(**validated_data, owner=instance)
return instance

View File

@ -603,7 +603,7 @@ class AuthenticationViewSet(viewsets.ViewSet):
content = {'code': 'wrong_host', 'detail': detail}
return Response(content, status=status.HTTP_400_BAD_REQUEST)
verify_key = nacl.signing.VerifyKey(user.userinfo.pubkey, encoder=nacl.encoding.RawEncoder)
verify_key = nacl.signing.VerifyKey(user.userinfo.loginPubkey, encoder=nacl.encoding.RawEncoder)
verify_key.verify(response_raw, signature)
data = self.login_response_data(user)