ToolypetMCP
intermediate3 minutessecurity

Two-Factor Authentication Setup

Implement TOTP-based 2FA with secret generation, QR code URI, and backup codes.

2fatotpauthenticationsecurity

Quando usar esta receita

Add an extra security layer to your application. TOTP-based 2FA is used by Google Authenticator, Authy, and other apps. Backup codes ensure users aren't locked out.

Etapas

1

Create the TOTP secret and QR URI

Prompt:Generate a TOTP secret for user@example.com with issuer 'MyApp', 6 digits, 30 second period
2

Create recovery backup codes

Prompt:Generate 10 backup codes (8 characters each, alphanumeric)
3

Hash backup codes before storing

Prompt:Hash the backup codes with SHA-256 for secure storage

Perguntas frequentes

TOTP vs SMS for 2FA — which is better?

TOTP is significantly more secure. SMS is vulnerable to SIM swapping and interception attacks. NIST recommends against SMS-based 2FA for sensitive applications.

How should I store TOTP secrets?

Encrypt TOTP secrets at rest using AES-256. They must be recoverable (unlike passwords which are hashed one-way) because the server needs the secret to verify codes.

Receitas relacionadas