Download the PHP package scriptoshi/livewire-2fa without Composer
On this page you can find all versions of the php package scriptoshi/livewire-2fa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scriptoshi/livewire-2fa
More information about scriptoshi/livewire-2fa
Files in scriptoshi/livewire-2fa
Package livewire-2fa
Short Description Simple two-factor authentication package for Laravel 12 using Livewire
License MIT
Informations about the package livewire-2fa
Laravel Livewire 2FA
A simple and elegant two-factor authentication package for Laravel 12 using Livewire and Flux components. Built to work seamlessly with Laravel 12's authentication stack.
Overview
Laravel 2FA provides an easy way to add Google Authenticator compatible two-factor authentication to your Laravel 12 application. Built with Livewire and Flux components, it offers a modern, interactive user experience with minimal configuration.
Features
- 🔒 Google Authenticator compatible (TOTP)
- ⚡ Livewire-powered interactive components
- 🎨 Beautiful UI with Flux components
- 🌓 Full dark mode support
- 🛠️ Simple integration with existing authentication systems
- 🔑 Recovery codes for account access backup
- 🛡️ On-demand password and 2FA confirmation modals
- 🔄 Compatible with Laravel 12 and Livewire 3
Requirements
- PHP 8.2+
- Laravel 12.x
- Livewire 3.x
- Flux components
Installation
1. Install the package via Composer
2. (optional) If you need to customize, publish the assets
3. Run the migrations
This will add the required columns to your users table.
4. Include the TwoFactorAuthenticatable trait in your User model
Configuration
The package comes with sensible defaults, but you can customize it using the corresponding .env
variables.
Add the following lines to your .env to customise the config
Basic Usage
Adding 2FA Management to User Profile
Add the Livewire component to your user profile page:
On Laravel 12 Starter kit:
-
Edit
resources/views/components/settings/layout.blade.php
and add: -
Create the two factor auth view:
resources/views/livewire/settings/twofactor.blade.php
- Add the route to
routes/web.php
:
Integrating with Login (Laravel 12 Starter Kit)
The easiest way to integrate 2FA with Laravel 12's Livewire login is by adding the WithTwoFactorAuthentication
trait directly to your login component:
- Update your
resources/views/livewire/auth/login.blade.php
Volt component:
update the Login method on the form submit from wire:submit="login"
to wire:submit="twoFactorLogin"
Include the 2FA Modal after the form closing tag.
That's it! The login component will now:
- Attempt normal login with email/password
- Check if the user has 2FA enabled
- If 2FA is enabled, show the 2FA modal for code verification
- Complete the login process after successful 2FA verification
Using Confirmation Modals
For sensitive actions in your application, you can require password or 2FA verification:
Password Confirmation Modal
-
Wrap the sensitive action in your component:
- Include the trait in your Livewire component:
Two-Factor Confirmation Modal
For even higher security, you can require 2FA confirmation for critical operations:
-
Include the modal component in your template:
- Include the trait in your Livewire component:
Customization
Views
Customize the views by publishing them and modifying as needed:
This will publish the views to resources/views/vendor/two-factor-auth/
.
Styling
The components use Flux components and support dark mode out of the box. You can customize the appearance by:
- Publishing the views (as shown above)
- Modifying the Flux component usage or class attributes
- For more extensive customization, you can extend or override the Livewire components
Using the Facade Directly
You can use the TwoFactorAuth
facade directly for advanced use cases:
License
This package is open-sourced software licensed under the MIT license.
All versions of livewire-2fa with dependencies
illuminate/support Version ^12.0
livewire/livewire Version ^3.0
pragmarx/google2fa Version ^8.0
bacon/bacon-qr-code Version ^3.0