two-factor-authentication-best-practices

Configure TOTP and OTP two-factor authentication with Better Auth plugin.

2|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/involvex/happy-vibecode --skill two-factor-authentication-best-practices-involvex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/involvex/happy-vibecode/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/involvex/happy-vibecode --skill two-factor-authentication-best-practices-involvex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implements multi-factor authentication to protect user accounts from unauthorized access by adding an additional verification layer beyond passwords, reducing account takeover risk and improving compliance.

Core Features & Use Cases

  • TOTP Authenticator Setup: Guides generating a TOTP URI, displaying a QR code, and verifying codes with clock drift tolerance.
  • OTP Delivery via Email/SMS: Covers sending, storing, and verifying short-lived OTPs with configurable period, digits, and attempt limits.
  • Backup Codes & Recovery: Generate single-use backup codes, display/regenerate them securely, and use them for account recovery.
  • Trusted Devices & Sign-in Flows: Handle trust-device tokens, temporary 2FA cookies during sign-in, and server/client redirection when two-factor is required.
  • Security Controls: Recommendations for encrypted storage of secrets and codes, rate limiting, and session management practices.

Quick Start

Enable TOTP and OTP for a user, generate the TOTP URI and backup codes, and present the QR code and backup codes to the user for safekeeping.

Frequently Asked Questions about two-factor-authentication-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up two-factor authentication with TOTP and OTP for my web application?

Two-factor authentication setup requires generating a TOTP URI, displaying a QR code, and verifying codes with clock drift tolerance. OTP delivery via email or SMS uses short-lived codes with configurable periods, digits, and attempt limits. Password verification is required before enabling.

What is the best way to manage backup codes for account recovery in a 2FA system?

Backup codes for 2FA account recovery are generated as single-use codes, displayed securely to the user for safekeeping, and can be regenerated when needed. Encrypted storage options ensure secrets and codes remain protected on the server.

Does this 2FA implementation support trusted devices and sign-in flows for mobile clients?

Two-factor authentication supports trusted devices and sign-in flows for both web and mobile clients by handling trust-device tokens, temporary 2FA cookies during sign-in, and server or client redirection when two-factor verification is required.

Can I configure rate limiting and encrypted storage for OTP and TOTP secrets?

Two-factor authentication configuration includes security controls for encrypted storage of secrets and codes, rate limiting to prevent brute-force attacks, and configurable TOTP and OTP parameters such as period, digits, and attempt limits.

How does two-factor authentication integrate with Better Auth?

Two-factor authentication integrates with the Better Auth twoFactor plugin to provide TOTP authenticator setup, OTP delivery via email or SMS, backup code management, and trusted device workflows with encrypted storage and rate limiting.