laravel/fortify
Laravel Fortify is a frontend-agnostic authentication backend for Laravel. It provides registration, login, password reset, email verification, and two-factor authentication endpoints and features used by Laravel starter kits, while letting you build your own UI.
Features, Rules, and Traits (e.g., InteractsWithTwoFactorState) allow granular customization without monolithic overrides. Example: Extending Features to toggle password resets or 2FA dynamically.TwoFactorAuthenticationEnabled, RecoveryCodeReplaced) for observability and extensibility, enabling integration with third-party services (e.g., analytics, audit logs).Auth scaffolding (e.g., LoginController, RegisterController) without requiring changes to existing business logic. Example: Swap Auth::attempt() with Fortify’s AttemptToAuthenticate trait.JsonResponse for 2FA flows).users table follows Laravel conventions.EnsureEmailIsVerified, RedirectIfTwoFactorAuthenticatable) for route protection, reducing boilerplate.composer.json and monitor Laravel’s release schedule.UpdateUserPassword to enforce org-specific rules.session()->regenerate().UserProvider can be extended, but conflicts may arise with non-Eloquent providers.laravel-debugbar or Blackfire.mail driver is configured.users table with email_verified_at, two_factor_secret, and two_factor_recovery_codes columns. Migrations are provided./sanctum/csrf-cookie).Auth::attempt(), custom guards). Identify conflicts with Fortify’s UserProvider./login). Fortify uses named routes (fortify.login).composer require laravel/fortify
php artisan fortify:install
config/fortify.php), migrations, and views.config/fortify.php for:
features.email_verification).two_factor_authentication).password_length).Fortify::useSanctum();
// or
Fortify::usePassport();
Auth::routes()) with Fortify’s:
Route::middleware('guest')->group(function () {
Route::get('/login', [Action::class, 'showLoginForm']);
Route::post('/login', [Action::class, 'store']);
// ... other routes
});
verified_user middleware).throttle), session fixation, CSRF.DatabaseUserProvider), extend FortifyUserProvider or override retrieveByCredentials().Auth or session logic (e.g., spatie/laravel-permission). Test with php artisan package:discover.Features class allows toggling functionality (e.g., disable password resets):
Fortify::disablePasswordResets();
Auth scaffolding with Fortify.UpdateUserProfileInformation).TwoFactorAuthenticationEnabled events).composer why-not laravel/fortify to track breaking changes.config/fortify.php to avoid hardcoded values across controllers.Features or Rules) in a CONTRIBUTING.md section to aid future maintainers.php artisan fortify:check to validate setup.config/fortify.php['debug'] = true) for verbose error messages.debugbar to inspect auth events (e.g., Authenticating).How can I help you explore Laravel packages today?