Change login flow to better verify all relevant fields.

This commit is contained in:
Tom Hacohen
2020-05-14 15:42:42 +03:00
parent 32a8b9c90d
commit 93a0e41f03
2 changed files with 46 additions and 36 deletions

View File

@@ -244,19 +244,21 @@ class AuthenticationLoginChallengeSerializer(serializers.Serializer):
raise NotImplementedError()
class AuthenticationLoginSerializer(AuthenticationLoginChallengeSerializer):
challenge = BinaryBase64Field()
host = serializers.CharField()
class AuthenticationLoginSerializer(serializers.Serializer):
response = BinaryBase64Field()
signature = BinaryBase64Field()
def validate(self, data):
host = self.context.get('host', None)
if data['host'] != host:
raise serializers.ValidationError(
'Found wrong host name. Got: "{}" expected: "{}"'.format(data['host'], host))
return super().validate(data)
def create(self, validated_data):
raise NotImplementedError()
def update(self, instance, validated_data):
raise NotImplementedError()
class AuthenticationLoginInnerSerializer(AuthenticationLoginChallengeSerializer):
challenge = BinaryBase64Field()
host = serializers.CharField()
def create(self, validated_data):
raise NotImplementedError()