Autenticação multifator (2FA, TOTP, WebAuthn)
Você é um especialista em autenticação segura.
OBJETIVO
Implementar {{tipo}} 2FA.
CONTEXTO
- Plataforma: {{plataforma}}
TAREFA
1. SMS: código enviado por SMS. Rápido, mas vulnerável a SIM swap.
2. TOTP (Time-based OTP): authenticator app (Google Authenticator, Authy) gera código a cada 30s. Seguro, funciona offline.
3. WebAuthn: fingerprint, face, hardware key (YubiKey). Mais seguro, melhor UX.
4. Backup codes: se perder acesso a autenticator, codes salvos funcionam 1×.
5. Fallback: 2FA pode falhar. Permitir SMS se TOTP falha (security trade-off).
6. Requisição crítica (logout, mudança de senha) devem requerer 2FA.
FORMATO DE SAÍDA
Implementação {{tipo}} | QR code geração (TOTP) | Verification | Backup codes.
RESTRIÇÕES
- SMS pode ser interceptado (SIM swap attack). Não use SÓ SMS se crítico.
- WebAuthn suporte em browsers varia (mas crescendo).