A flexible authentication kit for Filament that brings enhanced two-factor authentication, SMS login, and customizable login flows to your Laravel applications.
- Installation
- User Model Changes
- Configuration
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
First, install the package via Composer:
composer require aurorawebsoftware/filament-loginkitThen, run the install command to set up configuration, migrations, assets, and required dependencies:
php artisan filament-loginkit:installAdd the plugin to your PanelProvider:
plugin(FilamentLoginKitPlugin::make())To require two-factor authentication for all users, use the forced() method:
plugin(FilamentLoginKitPlugin::make()->forced())Make sure your User model implements the necessary properties and traits:
<?php
use AuroraWebSoftware\FilamentLoginKit\Traits\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use TwoFactorAuthenticatable;
protected $fillable = [
'phone_number',
'two_factor_type',
'is_2fa_required',
'sms_login_code',
'sms_login_expires_at',
'two_factor_code',
'two_factor_expires_at',
'is_active',
'whatsapp_login_code',
'whatsapp_login_expires_at'
];
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'sms_login_expires_at' => 'datetime',
'is_2fa_required' => 'boolean',
'two_factor_expires_at' => 'datetime',
'is_active'=>'boolean'
'whatsapp_login_expires_at' => 'datetime',
];
}After publishing the config file, you can find it at config/filament-loginkit.php.
Enable/disable email and SMS login:
'email_login' => env('LOGINKIT_EMAIL_LOGIN_ENABLED', true),
'sms_login' => env('LOGINKIT_SMS_LOGIN_ENABLED', false),Set available two-factor methods: authenticator, email, sms
'options' => [
\AuroraWebSoftware\FilamentLoginKit\Enums\TwoFactorType::authenticator,
\AuroraWebSoftware\FilamentLoginKit\Enums\TwoFactorType::email,
\AuroraWebSoftware\FilamentLoginKit\Enums\TwoFactorType::sms,
],Enable or disable registration, multi-tenancy, or generic error messages:
'enabled_features' => [
'register' => false,
'multi_tenancy' => false,
'generic_errors' => false,
],To enable SMS authentication, you must implement your own SMS service using the provided interface.
You can find the interface at:
AuroraWebSoftware\FilamentLoginKit\Contracts\SmsServiceInterfaceFirst, create a class that implements this interface. For example:
namespace App\Services;
use AuroraWebSoftware\FilamentLoginKit\Contracts\SmsServiceInterface;
class SmsService implements SmsServiceInterface
{
public function sendSms(string $phone, string $message): void
{
// Your SMS sending logic here
}
}Then, register your service in the configuration file:
// config/filament-loginkit.php
'sms_service_class' => \App\Services\SmsService::class,Note: Your SMS service must implement all methods required by SmsServiceInterface.
Limit login and 2FA attempts to prevent abuse:
'rate_limits' => [
'sms' => [
'max_requests' => 5,
'per_minutes' => 1,
],
'sms_resend' => [
'max_requests' => 2,
'per_minutes' => 1,
],
'login' => [
'max_requests' => 5,
'per_minutes' => 1,
],
'two_factor' => [
'max_requests' => 5,
'per_minutes' => 1,
],
],Set whether notifications are queued:
'queue_notifications' => env('LOGINKIT_QUEUE_NOTIFICATIONS', true),
'email_queue' => env('LOGINKIT_EMAIL_QUEUE', 'filament-loginkit'),
'sms_queue' => env('LOGINKIT_SMS_QUEUE', 'filament-loginkit'),The queue name used by Filament Loginkit is filament-loginkit.
To start the queue worker in Laravel, run the following command:
php artisan queue:work --queue=filament-loginkitAnd more! Please check the config/filament-loginkit.php file for the full list of options.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.