Mid-level Track Roadmap

Security: rack-attack

This course covers rate limiting for a Rails application, built around the repository's own sign-in, signup and password reset endpoints. It explains credential stuffing and other automated traffic, and where limits can sit: the edge, the proxy or the application. It compares Rails' built-in rate_limit with the Rack::Attack middleware and its safelist, blocklist, throttle and track rules. It also covers choosing what to count by, picking a shared store for counters, returning 429 with Retry-After, logging throttles, and rolling out rules in track mode first.

What you'll learn

  • ✓Why credential stuffing calls for limiting attempts, and what rate limiting cannot stop
  • ✓How Rails' rate_limit and Rack::Attack differ, and when to use both
  • ✓How to choose a discriminator: IP, account, API key or subnet
  • ✓Why the counter store must be shared and survive an attack
  • ✓How to respond with 429 and Retry-After, and log throttles by rule name
  • ✓How to roll out limits in track mode and test them with the limiter enabled
Free preview · Lesson 1 5 min read

The attack you will actually get

Read this repository's sign-in action:

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...