Pattern: Two-step sign-in, passkeys and social login

Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.

Search terms: two-factor, 2fa, mfa, totp, passkey, webauthn, sms otp, social login, oauth, openid connect, recovery codes, magic link

Last reviewed:

For agents

1. Problem

Passwords alone fall to leaked-password reuse and phishing. OWASP calls multi-factor authentication by far the best defense against most password-related attacks, including credential stuffing. The choice of method decides how much friction users feel and how much risk remains.

2. Options

Method Upside Downside When
Authenticator-app codes (TOTP, RFC 6238) Works offline; no phone number needed Codes can be phished in real time; setup friction Default second factor for most products
Passkeys (WebAuthn / FIDO) Phishing-resistant; no password to remember Newer; recovery and device-sync design needed Consumer apps, admin panels
SMS or call codes Familiar to users NIST treats the telephone network as a restricted authenticator; SIM swap and interception risk Only as a fallback with eyes open
Email code as a factor Everyone has email OWASP: email is a weak factor Low-risk step-up only
Magic link sign-in No password Depends on mailbox security and link handling Low-risk products
“Sign in with Google / Apple” No password to manage; users already trust the provider Third-party dependency; some users lack an account; account linking rules needed Consumer apps (see OpenID Connect Core)

4. Scenarios and edge cases

5. Common mistakes

6. How to audit

Sources