better-auth-security-best-practices

Configure rate limiting, CSRF protection, and session security for Better Auth instances.

Updated Apr 25, 2026
One-click install
npx skills add https://github.com/DevQwiet/my-skills --skill better-auth-security-best-practices-devqwiet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-security-best-practices
Source: https://github.com/DevQwiet/my-skills/tree/main/better-auth-security-best-practices
Command: npx skills add https://github.com/DevQwiet/my-skills --skill better-auth-security-best-practices-devqwiet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps users secure their Better Auth setup by implementing best practices for rate limiting, CSRF protection, session security, and other critical aspects of authentication security.

Core Features & Use Cases

  • Rate Limiting: Configure rate limiting to prevent brute force attacks and abuse of authentication endpoints.
  • CSRF Protection: Implement multi-layer CSRF protection to secure against cross-site request forgery.
  • Session Security: Set up secure session management with expiration, caching, and cookie security.
  • OAuth Security: Secure OAuth tokens and manage state tokens for OAuth flows.
  • IP-Based Security: Track and secure user IP addresses for additional security.
  • Database Hooks: Implement database hooks for security auditing and logging.
  • Background Tasks: Configure background tasks for non-blocking operations like email sending.
  • Account Enumeration Prevention: Prevent account enumeration with consistent error messages and dummy operations.
  • Complete Security Configuration: Provide a comprehensive example of security configuration for Better Auth.

Quick Start

Run the 'setup-auth-security' script to configure rate limiting, CSRF protection, and session security for your Better Auth instance.

Frequently Asked Questions about better-auth-security-best-practices

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

FAQPage Schema
How do I configure rate limiting in Better Auth to prevent brute force attacks?

Implement rate limiting in Better Auth to prevent brute force attacks by configuring endpoint request thresholds via the setup-auth-security script. This establishes necessary restrictions to block automated abuse attempts.

What is the best way to implement CSRF protection for Better Auth session management?

Implement multi-layer CSRF protection for Better Auth to secure session management against cross-site request forgery. This approach validates request origins and tokens to block unauthorized state-changing commands.

Does Better Auth support IP-based security tracking and OAuth state tokens?

Yes, Better Auth supports IP-based security tracking and OAuth state tokens. You can track user IP addresses for additional security layers and manage state tokens to secure OAuth flows effectively.

How do I prevent account enumeration in my authentication setup?

Prevent account enumeration in your authentication setup by configuring consistent error messages and dummy operations. This obscures valid user identities during login and registration attempts to block enumeration attacks.

Can I use database hooks in Better Auth for security auditing and logging?

Yes, you can use database hooks in Better Auth for security auditing and logging. This allows you to monitor authentication events and track security-related changes within your database operations.

How do I configure secure Better Auth cookies and session expiration?

Configure secure Better Auth cookies and session expiration by applying session security best practices. This establishes secure cookie attributes and automatic expiration policies to protect active user sessions.