Skip to main content

Fortify Hardening for Laravel

Laravel Fortify tells anyone who asks whether an email address has an account. Its registration form refuses a taken address with "The email has already been taken.", its reset-link form answers an unknown address with "We can't find a user with that email address.", and a password reset names the same difference. Each of those answers is enough to check a list of addresses against your application, one request at a time.

This package closes all three, and the difference in time behind them.

The notice in a mail program: from Linen & Co, hello@shop.example, to mira@example.com, with the subject "Someone tried to register at Linen & Co with your email address". It says that somebody tried to create an account with this address and that the holder already has one, offers a Sign in button, and adds that a forgotten password can be reset from the sign-in page and that nothing needs to be done if it was not the holder.

composer require pushery/fortify-hardening-for-laravel

The package is on Packagist, and the source and the issue tracker live at github.com/pushery/fortify-hardening-for-laravel.

Requirements​

  • PHP 8.4+ (tested on 8.4.27, 8.5.x and 8.6.x)
  • Laravel 13+
  • Laravel Fortify 1.34.1+, with its registration and resetPasswords features

What changes​

WhereFortify on its ownWith the package
Registrationa taken address is refused, a free one is signed inboth get "check your inbox", nobody is signed in, the holder of a taken address gets a notice
Reset linkan unknown address is refused, an address that asked a minute ago is told to waitevery request reads like a link that was sent
Password resetan unknown address and a wrong token give different errorsevery failure reads like a wrong token
Timinga taken address answers in a fraction of the time a free one takes, and a known address takes longer on the password routesboth answers take the same time
Sign-in limiterfailed sign-ins are counted under the address and the IP as they are, which then stand in the cache and in what an error tracker records, and again by the login limiter of your service provider under an MD5 a guessed address and IP computeFortify's count under a key hashed with the application key, and a helper that keys the login limiter the same way

The package keeps Fortify's routes, its controllers for everything else and your own actions. It puts its answers in place of Fortify's through the container, so there is no route to register and no view to publish.

Pages​

  • Installation: what to install, and the two things your application has to provide.
  • Registration: the neutral registration on Fortify's route, the notice to the holder, and the same flow from a controller of your own.
  • Password reset: the reset-link request and the reset itself.
  • Timing: why a neutral text is not enough, and how both answers come to take the same time.
  • Testing your application: the assertion the package ships, to prove the property in your own suite.
  • Configuration: every setting, its environment variable and its default, and the translations.
  • What it does not cover: the routes and the guarantees left to your application, and what to do about each.