mirror of
https://github.com/etesync/server
synced 2024-11-26 02:38:15 +00:00
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:
parent
2412c295de
commit
863c405802
18
django_etesync/migrations/0005_auto_20200526_1021.py
Normal file
18
django_etesync/migrations/0005_auto_20200526_1021.py
Normal 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',
|
||||||
|
),
|
||||||
|
]
|
@ -174,7 +174,7 @@ class CollectionInvitation(models.Model):
|
|||||||
class UserInfo(models.Model):
|
class UserInfo(models.Model):
|
||||||
owner = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, primary_key=True)
|
owner = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, primary_key=True)
|
||||||
version = models.PositiveSmallIntegerField(default=1)
|
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)
|
salt = models.BinaryField(editable=True, blank=False, null=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -348,13 +348,11 @@ class UserInfoPubkeySerializer(serializers.ModelSerializer):
|
|||||||
class AuthenticationSignupSerializer(serializers.Serializer):
|
class AuthenticationSignupSerializer(serializers.Serializer):
|
||||||
user = UserQuerySerializer(many=False)
|
user = UserQuerySerializer(many=False)
|
||||||
salt = BinaryBase64Field()
|
salt = BinaryBase64Field()
|
||||||
pubkey = BinaryBase64Field()
|
loginPubkey = BinaryBase64Field()
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
"""Function that's called when this serializer creates an item"""
|
"""Function that's called when this serializer creates an item"""
|
||||||
user_data = validated_data.pop('user')
|
user_data = validated_data.pop('user')
|
||||||
salt = validated_data.pop('salt')
|
|
||||||
pubkey = validated_data.pop('pubkey')
|
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
instance, _ = User.objects.get_or_create(**user_data)
|
instance, _ = User.objects.get_or_create(**user_data)
|
||||||
@ -364,7 +362,7 @@ class AuthenticationSignupSerializer(serializers.Serializer):
|
|||||||
instance.set_unusable_password()
|
instance.set_unusable_password()
|
||||||
# FIXME: send email verification
|
# FIXME: send email verification
|
||||||
|
|
||||||
models.UserInfo.objects.create(salt=salt, pubkey=pubkey, owner=instance)
|
models.UserInfo.objects.create(**validated_data, owner=instance)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ class AuthenticationViewSet(viewsets.ViewSet):
|
|||||||
content = {'code': 'wrong_host', 'detail': detail}
|
content = {'code': 'wrong_host', 'detail': detail}
|
||||||
return Response(content, status=status.HTTP_400_BAD_REQUEST)
|
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)
|
verify_key.verify(response_raw, signature)
|
||||||
|
|
||||||
data = self.login_response_data(user)
|
data = self.login_response_data(user)
|
||||||
|
Loading…
Reference in New Issue
Block a user