deux.serializers¶
-
class
deux.serializers.BackupCodeSerializer[source]¶ Serializer for the user requesting backup codes.
-
backup_code= None¶ Serializer field for the backup code.
-
-
class
deux.serializers.MultiFactorAuthSerializer[source]¶ Basic MultiFactorAuthSerializer that encodes MFA objects into a standard response.
The standard response returns whether MFA is enabled, the challenge type, and the user’s phone number.
-
class
deux.serializers.SMSChallengeRequestSerializer[source]¶ Serializer that facilitates a request to enable MFA over SMS.
-
challenge_type= u'sms'¶ This serializer represents the
SMSchallenge type.
-
update(mfa_instance, validated_data)[source]¶ If the request data is valid, the serializer executes the challenge by calling the super method and also saves the phone number the user requested the SMS to.
Parameters: - mfa_instance –
MultiFactorAuthinstance to use. - validated_data – Data returned by
validate.
- mfa_instance –
-
-
class
deux.serializers.SMSChallengeVerifySerializer[source]¶ Extension of
_BaseChallengeVerifySerializerthat implements challenge verification for the SMS challenge.-
challenge_type= u'sms'¶ This serializer represents the
SMSchallenge type.
-
-
class
deux.serializers._BaseChallengeRequestSerializer[source]¶ Base Serializer class for all challenge request.
-
challenge_type¶ Represents the challenge type this serializer represents.
Raises: NotImplemented – If the extending class does not define challenge_type.
-
execute_challenge(instance)[source]¶ Execute challenge for this instance based on the
challenge_type.Parameters: instance – MultiFactorAuthinstance to use.Raises: serializers.ValidationError – If the challenge fails to execute.
-
update(mfa_instance, validated_data)[source]¶ If the request is valid, the serializer calls update which executes the
challenge_type.Parameters: - mfa_instance –
MultiFactorAuthinstance to use. - validated_data – Data returned by
validate.
- mfa_instance –
-
validate(internal_data)[source]¶ Validate the request to enable MFA through this challenge.
Extending classes should extend for additional functionality. The base functionality ensures that MFA is not already enabled.
Parameters: internal_data – Dictionary of the request data. Raises: serializers.ValidationError – If MFA is already enabled.
-
-
class
deux.serializers._BaseChallengeVerifySerializer[source]¶ This serializer first extracts MFA code from request body (to_internal_value). It then verifies the code against the corresponding MultiFactorAuth instance (validate). If the code is valid, it enables MFA based on the challenge type (update).
-
challenge_type¶ Represents the challenge type this serializer represents.
Raises: NotImplemented – If the extending class does not define challenge_type.
-
mfa_code= None¶ Requests to verify an MFA code must include an
mfa_code.
-
update(mfa_instance, validated_data)[source]¶ If the request is valid, the serializer enables MFA on this instance for this serializer’s
challenge_type.Parameters: - mfa_instance –
MultiFactorAuthinstance to use. - validated_data – Data returned by
validate.
- mfa_instance –
-
validate(internal_data)[source]¶ Validates the request to verify the MFA code. It first ensures that MFA is not already enabled and then verifies that the MFA code is the correct code.
Parameters: internal_data – Dictionary of the request data. Raises: serializers.ValidationError – If MFA is already enabled or if the inputted MFA code is not valid.
-