Skip to main content

What it does not cover

The package closes what Fortify's registration and password reset tell a caller. Some questions about an address can still be asked elsewhere in an application, and some of what the package does has edges worth knowing.

Signing in​

Fortify already answers a failed sign-in with the same message, whether the address has an account or the password is wrong. What still differed was the time: a known address costs a password check and an unknown one does not. The package closes that through the minimum duration, which Laravel applies to a failed sign-in as well. With Fortify's two-factor feature on, Fortify checks the password in a step of its own before the guard, and the package holds that step to the same minimum. A callback your application sets with Fortify::authenticateUsing() checks the password in place of the guard, which Fortify holds to no minimum below release 1.44.0, so the package holds Fortify's step that calls it, AttemptToAuthenticate, to the same minimum as well. The two-factor challenge itself and passkeys come after a successful credential check and are not touched.

Changing the address of an account​

Fortify's UpdateUserProfileInformation stub checks a new address with a unique rule. A signed-in user can therefore try other people's addresses one at a time and read the answer. The package does not cover this route, because the answer belongs to the application: the user changing their address is allowed to learn that it is in use. If that is not acceptable, accept every address, send a confirmation link to the new one, and switch only once it is confirmed, and throttle the route either way.

A username of its own​

Where people sign in with a username of their own, fortify.username naming another field than fortify.email, the package leaves Fortify's registration in place. A taken username has to be refused for the person to choose another, and the package's controller would reach that refusal only for a free address, so its answer would tell a free address from a taken one. Fortify's registration then refuses a taken address and a taken username with a validation error and signs a new account in, as it does without the package. The registration page shows how a controller of your own keeps the address closed.

The application's own endpoints​

An invitation form, a newsletter sign-up, an API that checks whether an address is free, or a front end that validates the address while the user types can each answer the same question. Use the assertion on those endpoints as well.

Requests are not throttled​

The package counts mails per address, not requests. Keep a throttle on the registration route and on the password routes: it stops a caller from trying many addresses quickly, which the neutral answers make pointless but do not make cheap.

The store of the mail budget​

The mail budget lives only in a cache store, the one Laravel's rate limiter uses. A store that loses a count before its hour is over starts the budget of that address again, and the next registration mails the address once more, and one that loses the note holding back a verification mail lets that mail go out: by eviction under memory pressure (Redis under any maxmemory-policy but noeviction, Memcached without -M), by a cache:clear or optimize:clear that flushes it, or by a restart without persistence (Redis without appendonly yes, Memcached every time). The package cannot read the policy of a store, so choose one that keeps its keys, as the registration page describes. A Redis under noeviction that has filled up refuses every write instead of dropping a key.

Equal, not constant time​

The package removes the systematic differences in time: the password hash, the work of the password broker, and the work a new account costs beyond its hash, which the registration keeps inside the minimum duration. A request's duration still varies with the load of the server and the network, and work that runs past the minimum duration shows again: a CreatesNewUsers action or a listener of Registered that takes longer than the minimum, or mail sent through a slow transport while the request waits. Queue mails, keep the minimum above the time your slowest server needs for one hash and for one registration, and measure on your own infrastructure if the difference matters to you.