Laravel Authentication Security Checklist
Harden your Laravel authentication system against brute-force attacks, session hijacking, and credential theft with this security checklist.
Password & Credential Security
Use Laravel's Password::min(8) validation rule. Consider requiring 12+ characters for sensitive applications. Longer passwords are significantly harder to crack than short complex passwords.
Laravel uses bcrypt by default, which is secure. For higher security, switch to Argon2id in config/hashing.php. Never use MD5, SHA-1, or SHA-256 for password hashing — they are too fast to resist brute-force.
Use Laravel's Password::uncompromised() validation rule to check passwords against the Have I Been Pwned database. This prevents users from choosing passwords that are already in known breach databases.
This includes log files, email notifications, and admin panels. Ensure password fields are never logged, and use the hidden cast or $hidden property on the User model.
Use Laravel's built-in login throttling or implement a lockout mechanism that temporarily blocks login attempts after 5 consecutive failures. This prevents brute-force attacks.
Session Security
In config/session.php, set secure to true (HTTPS only), http_only to true (no JavaScript access), and same_site to lax or strict. This prevents session theft via XSS and CSRF.
Call session()->regenerate() after successful authentication to prevent session fixation attacks. Laravel's built-in authentication does this automatically, but verify it if you have custom login logic.
Configure lifetime in config/session.php based on your application's sensitivity. Financial applications should use shorter lifetimes (15-30 minutes). Set expire_on_close to true for sensitive applications.
The file session driver works for development but can have issues with load balancers and does not support easy session management. Use database or Redis for production deployments.
When a user changes their password, invalidate all other active sessions. Laravel provides Auth::logoutOtherDevices($password) for this purpose. This ensures compromised sessions are terminated.
Multi-Factor Authentication & Advanced Security
Use Laravel Fortify or Jetstream's built-in 2FA support. TOTP-based 2FA (Google Authenticator, Authy) adds a second layer that protects accounts even if passwords are compromised.
Generate one-time recovery codes that users can store safely for account recovery if they lose access to their 2FA device. Laravel Fortify handles this automatically.
Apply throttle middleware to password reset and email verification endpoints. Without rate limiting, these endpoints can be used for email bombing and user enumeration.
Return "Invalid credentials" instead of "User not found" or "Incorrect password". Specific messages allow attackers to enumerate valid email addresses and usernames.
Log successful logins, failed attempts, password changes, and 2FA events. Include IP addresses and user agents. This data is essential for detecting unauthorized access and forensic analysis.
Frequently Asked Questions
Is bcrypt still secure for password hashing in Laravel?
Yes. Bcrypt remains a secure choice for password hashing. It is intentionally slow, which makes brute-force attacks impractical. Laravel's default bcrypt cost factor of 12 is appropriate for most applications. Argon2id offers additional resistance to GPU-based attacks if needed.
Should I implement 2FA for all users or just admins?
At minimum, require 2FA for admin and privileged accounts. For applications handling sensitive data (financial, healthcare, personal), offer 2FA to all users and strongly encourage or require it. Laravel Jetstream makes adding 2FA straightforward.
How do I prevent user enumeration through login and password reset forms?
Use the same response for valid and invalid email addresses. For login, return "Invalid credentials" regardless of whether the email exists. For password reset, always say "If an account exists, we've sent a reset link." Laravel's default password reset already follows this pattern.
Related Fix Guides
How to Fix an Exposed .env File in Laravel
Your Laravel .env file is publicly accessible, exposing database credentials and API keys. Learn how to block access and secure your secrets.
How to Fix Debug Mode Enabled in Production Laravel
APP_DEBUG=true in production exposes stack traces, environment variables, and database credentials. Learn how to disable it safely.
How to Fix Missing Security Headers in Laravel
Your Laravel app is missing critical security headers like CSP, HSTS, and X-Frame-Options. Learn how to add them with middleware.
Other Checklists
Laravel Production Deployment Security Checklist
A comprehensive security checklist for deploying Laravel applications to production. Covers environment config, server hardening, access control, and monitoring.
Laravel API Security Checklist
Secure your Laravel API endpoints against common vulnerabilities. Covers authentication, input validation, rate limiting, and response security.
Laravel Pre-Launch Security Checklist
Essential security checks to complete before launching your Laravel application. Covers code review, configuration audit, infrastructure, and monitoring setup.
Automate These Checks with StackShield
Stop running through checklists manually. StackShield continuously monitors your Laravel application for the security issues that matter most.
Start Free Trial