Timing
An answer can read the same and still tell the caller which case it was, by how long it took. A password is stored as a bcrypt hash, and at Laravel's default cost of 12 rounds one hash takes in the order of a quarter of a second. Whichever answer pays for a hash that the other one does not is that much slower, and a single request shows it.
Registration
Creating an account hashes its password, and finding a taken address does not. Without the package a taken address is answered in a fraction of the time a free one takes.
The package has both outcomes pay the same hash. On Fortify's route your CreatesNewUsers action
hashes the password of a new account, and for a taken address the package hashes the same password
with the same hasher. The registrar hashes the
password once, before the address is looked up, and hands the hash to the code that creates the
account.
Both outcomes also send one mail: the verification mail of a new account, or the notice to the holder of a taken address. Send them the same way. Laravel sends the verification mail at once, and so does the package's notice; an application that queues the one queues the other, as shown in Registration.
The minimum duration
The password routes work the other way round. For an address with an account the broker creates a token, which costs a hash, and sends the link; for an address without one it does neither. Laravel holds these requests, and a failed sign-in, to a minimum duration called a timebox, so that the short case waits until the long one would be done. Its default is 200 milliseconds, which is less than the hash alone, so the case with an account still takes longer.
The package raises that minimum to one second by setting auth.timebox_duration, unless your
application sets that key itself. A failed sign-in, every reset-link request and a failed reset
then take one second, with an account or without. A successful sign-in and a successful reset still
return at once.
With Fortify's two-factor feature on, the sign-in checks the password in a step of Fortify's own
before the guard does. From release 1.40 on, Fortify holds a failure there to 200 milliseconds,
and earlier releases do not hold it at all. The package holds
that step to the same minimum as the guard, whether the step is Fortify's or one your application
binds with Fortify::redirectUserForTwoFactorAuthenticationUsing(). A login pipeline of your own,
in fortify.pipelines.login or through Fortify::authenticateThrough(), is held where it names
the contract Laravel\Fortify\Contracts\RedirectsIfTwoFactorAuthenticatable, not where it names a
class.
| Setting | Default |
|---|---|
timebox. | 1000000, one second |
FORTIFY_ | the same, from the environment |
Set it to 0 to leave Laravel's own minimum in place. A value of your own in
auth.timebox_duration always wins over the package's.
The minimum only hides work that finishes inside it. Queue the reset-link notification, so that sending the mail is not part of the request, and keep the minimum above the time your slowest server needs for one hash.
The key of the sign-in limiter
Fortify counts failed sign-ins per address and IP, five a minute, and keeps the count in your cache under a key made of the lower-cased address and the IP as they are. Every failed attempt writes that key and a successful one clears it, so both stand in Redis or the cache table, and an error tracker such as Sentry or Flare records the key with every cache call it traces.
The package binds its own LoginRateLimiter in place of Fortify's. It counts under the same pair,
hashed with your application key: the count, the limit and the wait are Fortify's, and the key no
longer names who tried to sign in from where. Counts that are running when you deploy the package, or
when you change the application key, start again.
Switch it off with FORTIFY_HARDENING_HASHED_LOGIN_KEYS=false if you read those keys yourself. A
limiter of your own that you bind to Fortify's class after the package boots replaces this one.