TIP 02 / 09

Enable Two-factor Authentication with Fortify.

Laravel Fortify provides a TOTP-based two-factor sign-in flow, including challenge and recovery-code support. Install Fortify and run its published migrations, then add its trait to the authenticatable user model:

php
use Laravel\Fortify\TwoFactorAuthenticatable;

class User extends Authenticatable
{
    use TwoFactorAuthenticatable;
}

Enable the feature in config/fortify.php and require both code confirmation and password confirmation before changing the setting:

php
use Laravel\Fortify\Features;

'features' => [
    Features::twoFactorAuthentication([
        'confirm' => true,
        'confirmPassword' => true,
    ]),
],

Build account controls that let users scan the QR code, confirm a valid code, and save recovery codes securely. Do not consider setup complete until the user confirms the authenticator code.