better-auth-security-best-practices

Configure Better Auth security with rate limiting, CSRF protection, and session safeguards.

5.2k|543|Updated Jan 27, 2015
One-click install
npx skills add https://github.com/lukevella/rallly --skill better-auth-security-best-practices-lukevella
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-security-best-practices
Source: https://github.com/lukevella/rallly/tree/main/.agents/skills/better-auth-security-best-practices
Command: npx skills add https://github.com/lukevella/rallly --skill better-auth-security-best-practices-lukevella

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides guidance for implementing security features that span across Better Auth, including rate limiting, CSRF protection, session security, trusted origins, secret management, OAuth security, IP tracking, and security auditing. These topics are not covered in individual plugin skills.

Core Features & Use Cases

  • Rate limiting to protect authentication endpoints and APIs.
  • CSRF protection layers including origin checks and Fetch Metadata.
  • Trusted origins and dynamic origin handling for secure redirects.
  • Session and cookie security practices, including cookies attributes and cross-subdomain cookies.
  • OAuth/security practices including PKCE, state tokens, and encrypting tokens.
  • IP-based security measures and proxy header handling.
  • Security auditing via database hooks and background task considerations.
  • End-to-end configuration examples and a checklist to secure deployments.

Quick Start

Review the guidelines and implement the recommended configurations in your Better Auth setup to apply best practices.

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 and CSRF protection in Better Auth?

Better Auth security best practices involve configuring rate limiting to protect authentication endpoints and applying CSRF protection layers including origin checks and Fetch Metadata validation. These configurations safeguard APIs from abusive traffic and cross-site request forgery attacks.

What's the best way to handle trusted origins and dynamic redirects with Better Auth?

Handling trusted origins in Better Auth requires establishing concrete configuration requirements for dynamic origin handling to ensure secure redirects. This prevents open redirect vulnerabilities by validating redirect targets against an explicit allowlist of trusted origins before processing authentication callbacks.

How does Better Auth manage session and cookie security across subdomains?

Better Auth manages session and cookie security by enforcing strict cookie attributes and supporting cross-subdomain cookie configurations. Implementing these recommended defaults ensures that session tokens remain protected against interception while maintaining valid authentication states across related subdomains.

Can I use OAuth security practices like PKCE and state tokens with Better Auth?

Yes, Better Auth supports OAuth security practices including PKCE, state tokens, and token encryption. Implementing these measures protects authorization flows by validating request origins and encrypting stored tokens to prevent interception and unauthorized access during the OAuth exchange process.

How do I implement security auditing and IP tracking in Better Auth?

Security auditing in Better Auth is implemented via database hooks and background task considerations to log authentication events. IP tracking measures require proper proxy header handling to accurately identify client IPs behind reverse proxies for reliable audit trails.

Why do I need to verify secret management and error handling for Better Auth deployments?

Verifying secret management and safe error handling is required for Better Auth deployments to prevent sensitive data leakage. Establishing verification steps ensures secrets are properly managed and authentication errors return generic messages, avoiding exposure of system internals to attackers.