woob.browser.mfa
¶
- class TwoFactorBrowser(*args, **kwargs)[source]¶
Bases:
LoginBrowser
,StatesMixin
Browser which inherits from
LoginBrowser
to implement 2FA authentication.- Parameters:
config (
BackendConfig
) – configuration of the backend
- TWOFA_DURATION: ClassVar[int | float | None] = None¶
Period to keep the same state
It is different from STATE_DURATION which updates the expire date at each dump.
- INTERACTIVE_NAME: ClassVar[str] = 'request_information'¶
Config’s key which is set to a non-empty value when we are in interactive mode.
- AUTHENTICATION_METHODS: ClassVar[Dict[str, Callable]] = {}¶
Dict of config keys and methods used for double authentication.
Must be set up in the init to handle function pointers.
- COOKIES_TO_CLEAR: ClassVar[Tuple[str, ...]] = ()¶
List of cookie keys to clear before dumping state
- HAS_CREDENTIALS_ONLY: ClassVar[bool] = False¶
Login can also be done with credentials without 2FA
- SKIP_LOCATE_BROWSER_ON_CONFIG_VALUES: ClassVar[Tuple[str, ...]] = ()¶
Skip locate_browser if one of the config values is defined (for example its useful to prevent calling twice the url that sends an OTP)
- dump_state()[source]¶
Dump the current state in a
state
object.Can be overloaded by the browser subclass.
- init_login()[source]¶
Abstract method to implement initiation of login on website.
This method should raise an exception.
SCA exceptions : - AppValidation for polling method - BrowserQuestion for SMS method, token method etc.
Any other exceptions, default to BrowserIncorrectPassword.
- do_double_authentication()[source]¶
This method will check AUTHENTICATION_METHODS to dispatch to the right handle_* method.
If no backend configuration could be found, it will then call init_login method.
- do_login()¶
This method will check AUTHENTICATION_METHODS to dispatch to the right handle_* method.
If no backend configuration could be found, it will then call init_login method.