Rate Limiting Logins Without Locking Out Real Users
Sliding windows, per-IP buckets and friendly error messages: our approach to brute-force protection.
We publish security fixes as point releases with a short advisory, and the admin shows a banner until the update is installed.
The threat
New installs require two-factor authentication for every admin account. Recovery codes are shown once and can be regenerated from the profile screen.
Login attempts are rate limited per account and per IP address with a sliding window, which slows attackers without locking out real users.
- Two-factor authentication on by default
- Sliding-window login rate limits
- CSRF tokens on every form
- Signed and timed password reset links
“Security is a process, not a product.”
— Bruce Schneier
Our default
Every form carries a CSRF token, and every state-changing request is checked on the server, not just hidden in the interface.
RateLimiter::for('login', function (Request $request) {
return Limit::perMinute(5)->by($request->input('email') . $request->ip());
});
How to change it
Hardware security keys work anywhere two-factor codes do, and we recommend them for anyone with access to payments.
Sessions expire after a period of inactivity that each site owner can tune from the security settings.
Secrets are read from the environment at runtime and never written to the database or the logs.
Security defaults matter more than security options, because most people never change a default.
How we work on posts like this
We keep posts updated rather than writing new ones for every small change. When a step changes in a later release, the post gets an edit note at the top with the date and the version, so returning readers can see what moved without rereading everything.
Mistakes stay visible. If a post turns out to be wrong, we correct it in place, mark the correction and explain what we got wrong, rather than quietly swapping the text. Readers trust a build log more when they can see it being honest about its errors.
Our editing rule of thumb is to cut anything that would not change what the reader does next. Background and history are welcome when they explain a decision, but a post that only tells a story without leaving the reader able to do something is usually a draft that is not finished yet.
Finally, every post gets a real person as its author. The name on the card is the person who did the work and who will answer the comments, which keeps the writing specific and gives readers someone to hold to account when something does not work as described.
Every post on this blog starts as a note in the issue that shipped the change. When the work is done, whoever built it writes a first draft while the details are still fresh, and someone who did not work on it edits the draft for clarity. That second reader catches the jargon and the missing steps that the author can no longer see.
Questions or a better approach? Leave a comment below, or reply to the build-log email and we will fold the best ideas into the next release.
Clear, practical and no fluff. Thank you.
Same here, this saved me an afternoon.
Seconding this request.
Seconding this request.
Small nitpick: the second step assumes Redis is already installed. Might be worth a note.
Bookmarked. Our support team is going to use this as onboarding material.
How long did this take you end to end? Trying to plan our own migration.
Good catch, I have updated the post with a note about it.
Glad it helped. Let us know how the migration goes.
Would you share the full config file? The snippet is helpful but I am missing context.