Download the PHP package sicaboy/laravel-mfa without Composer
On this page you can find all versions of the php package sicaboy/laravel-mfa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sicaboy/laravel-mfa
More information about sicaboy/laravel-mfa
Files in sicaboy/laravel-mfa
Package laravel-mfa
Short Description A Laravel package of Multi-factor Authentication (MFA/2FA) with a middleware.
License MIT
Homepage https://github.com/sicaboy/laravel-mfa
Informations about the package laravel-mfa
Laravel Multi-factor Authentication (MFA) / Two-factor Authentication (2FA)
Introduction
A powerful and flexible Laravel package that provides Multi-factor Authentication (MFA) / Two-factor Authentication (2FA) middleware to secure your Laravel applications. This package was originally part of sicaboy/laravel-security and has been moved to this dedicated repository.
Features
- ✅ Easy Integration - Simple middleware-based implementation
- ✅ Email-based MFA - Secure code delivery via email
- ✅ Multiple Auth Guards - Support for different authentication contexts (user, admin, etc.)
- ✅ Configurable - Flexible configuration options
- ✅ Queue Support - Background email sending with Laravel queues
- ✅ Cache-based - Efficient code storage and verification tracking
- ✅ Customizable Views - Override templates to match your design
- ✅ Laravel 5.7+ Support - Compatible with modern Laravel versions
[!NOTE]
🚀 Advertisement: Don't Want to Build Authentication From Scratch?
Save weeks of development time with Users.au - a complete authentication solution for Laravel!
Why Choose Users.au?
- 🎯 Ready-to-use Authentication - Complete user management system
- 🔐 Built-in MFA/2FA - No need for additional packages
- ⚡ Laravel Integration - Seamless setup with your existing Laravel app
- 🆓 Free to Start - Get started without any upfront costs
- 🛠️ Developer-friendly - Multiple integration options
Get Started in Minutes:
Option 1: Laravel Starter Kit (Fastest)
Option 2: Add to Existing Laravel App
Option 3: Socialite Integration
Resources:
- 🌐 Website: https://www.users.au
- 📦 Laravel Starter Kit: https://github.com/Users-au/laravel-starter-kit
- 🔧 Laravel Package: https://github.com/Users-au/laravel-client
- 🔑 Socialite Provider: https://github.com/Users-au/socialite-provider
Skip the complexity of building authentication from scratch and focus on what makes your app unique!
Installation
Requirements
- PHP 7.1+ or 8.0+
- Laravel 5.7+
- Composer
Install via Composer
Publish Configuration and Views
This will publish:
- Configuration file:
config/laravel-mfa.php
- View templates:
resources/views/vendor/laravel-mfa/
Service Provider Registration (Laravel < 5.5)
If you're using Laravel < 5.5, manually register the service provider in config/app.php
:
Usage
Basic Usage
Protect your routes by applying the mfa
middleware:
Multiple Authentication Guards
If you use multiple authentication guards (e.g., separate user and admin authentication), specify the guard group:
Configure the corresponding group in config/laravel-mfa.php
:
Configuration Options
Email Configuration
Configure email settings in config/laravel-mfa.php
:
Code Expiration
Set how long verification codes remain valid:
Queue Configuration
For applications with queue workers running, enable background email sending:
Make sure your queue worker is running:
API Responses
The middleware provides JSON responses for API requests:
- 403 - User not authenticated
- 423 - MFA verification required
Testing
Run the test suite:
Or run PHPUnit directly:
Security Considerations
- Codes expire after the configured time limit (default: 10 minutes)
- Verification status is cached to prevent replay attacks
- Email delivery can be queued for better performance
- Multiple authentication contexts are supported
Roadmap
- ✅ Email-based MFA
- 🔄 SMS-based MFA
- 🔄 TOTP/Authenticator app support
- 🔄 User-specific MFA settings
- 🔄 Backup codes
Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development Setup
-
Clone the repository:
-
Install dependencies:
- Run tests:
Running Tests
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
Support
- Issues: GitHub Issues
- Documentation: This README and inline code documentation
- Email: [email protected]
Credits
- David Shen
- All Contributors