Two-factor authentication
Двухфакторная аутентификация
Signing in with two-factor authentication requires two different kinds of proof, such as a password and a code from an authenticator app. Knowing the password alone is not enough.
Also known as: 2FA, MFA
What counts as a factor?
An authentication factor is a kind of evidence that you are the person entitled to use an account. The three common categories are something you know (a password or PIN), something you have (a security key or a device holding an authenticator secret), and something you are (a biometric characteristic such as a fingerprint).
Two-factor authentication (2FA) requires proof from two different categories. The number of screens or prompts doesn't matter: asking for a password and then a security-question answer checks knowledge twice. By contrast, a hardware key that requires a PIN before it can authenticate can check both possession and knowledge in one operation. Multi-factor authentication (MFA) is the broader term for authentication with two or more factors.
Example: a password and an authenticator app
During setup, the service provisions a shared secret, often by showing a QR code that the user scans with an authenticator app. At sign-in, the app uses the secret and the current time to generate a time-based one-time password (TOTP). The server has its own copy of the secret and calculates which code to accept. The phone does not need a network connection to generate the code.
In this flow, a correct password starts a pending sign-in; it does not grant access to the account. The server limits code guesses and rejects reuse of an already accepted code, even if its time window is still open. It issues a fully authenticated session only after the second check succeeds.
Choosing a method and planning for recovery
Email providers, workplace identity systems, and admin consoles use 2FA to reduce the risk from stolen passwords. But adding a factor doesn't automatically make a sign-in phishing-resistant. A TOTP code can be entered on a fake page and relayed before it expires. A WebAuthn security key instead produces a cryptographic response bound to the site, so a response for a lookalike site won't authenticate the user to the legitimate one.
Plan for a lost phone or key before it happens. Users can enroll a spare security key or store single-use recovery codes somewhere separate from their primary device. Treat replacing an enrolled factor as a sensitive operation: require fresh verification rather than assuming that anyone with an active session should be allowed to change it.
What interviewers look for
In a login design question, explain how the server distinguishes a pending sign-in from an authenticated session. For instance, you can create a short-lived sign-in attempt tied to the account after the password check. That attempt should allow the user to complete the second-factor challenge, not to call protected APIs.