deux.services¶
-
class
deux.services.MultiFactorChallenge(instance, challenge_type)[source]¶ A class that represents a supported challenge and has the ability to execute the challenge.
Parameters: - instance –
MultiFactorAuthinstance to use. - challenge_type – Challenge type being used for this object.
Raises: AssertionError – If
challenge_typeis not a supported challenge type.- instance –
-
deux.services.generate_mfa_code(bin_key, drift=0)[source]¶ Generates an MFA code based on the
bin_keyfor the current timestamp offset by thedrift.Parameters: - bin_key – The secret key to be converted into an MFA code
- drift – Number of time steps to shift the conversion.
-
deux.services.verify_mfa_code(bin_key, mfa_code)[source]¶ Verifies that the inputted
mfa_codeis a valid code for the given secret key. We check themfa_codeagainst the current time stamp as well as one time step before and after.Parameters: - bin_key – The secret key to verify the MFA code again.
- mfa_code – The code whose validity this function tests.