two-factor-authentication-best-practices

Configure Better Auth twoFactor plugin with TOTP, backup codes, and rate limiting.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/stamatim/agent-skills --skill two-factor-authentication-best-practices-stamatim
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/stamatim/agent-skills/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/stamatim/agent-skills --skill two-factor-authentication-best-practices-stamatim

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Guides developers to implement and enforce secure two-factor authentication using Better Auth's twoFactor plugin, reducing misconfigurations and security gaps.

Core Features & Use Cases

  • Guided setup: Clear steps to configure issuer, 2FA flow, and client integration.
  • Comprehensive controls: Supports TOTP, OTP, backup codes, trusted devices, and encrypted storage.
  • Security guardrails: Includes rate limiting, session handling, and recovery options to minimize risk.

Quick Start

Configure a sample Better Auth setup with appName 'My App' and enable twoFactor using default options.

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 configure two-factor authentication with Better Auth?▼

Configure two-factor authentication by integrating Better Auth's twoFactor plugin, setting the appName issuer, enabling TOTP and OTP flows, and applying session management guardrails for secure credential-based accounts.

What is the best way to handle TOTP and backup codes in a 2FA flow?▼

The best way to handle TOTP and backup codes involves configuring encrypted storage at rest, enforcing rate limiting, and providing recovery options to minimize security risks during the two-factor authentication process.

Does Better Auth support trusted devices and 2FA recovery options?▼

Better Auth supports trusted devices and recovery options through its twoFactor plugin, offering comprehensive controls that include backup codes, encrypted storage, and session handling to secure user accounts.

How do I set up rate limiting for OTP verification in two-factor authentication?▼

Set up rate limiting for OTP verification by applying the security guardrails provided in the twoFactor plugin configuration, minimizing brute force risks during the two-factor authentication flow.

When do I need to encrypt TOTP secrets at rest for two-factor authentication?▼

You need to encrypt TOTP secrets at rest whenever implementing two-factor authentication for modern applications, ensuring robust configuration and preventing unauthorized access to sensitive credential data.

What are the limitations of using default 2FA options in Better Auth?▼

Default 2FA options provide basic setup but require additional configuration of encryption, rate limiting, and session management guardrails to fully secure credential-based accounts and prevent misconfigurations.