stephenjude/filament-two-factor-authentication
Composer 安装命令:
composer require stephenjude/filament-two-factor-authentication
包简介
Filament Two Factor Authentication: Google 2FA + Passkey Authentication
README 文档
README
Filament Two Factor Authentication (2FA)
Add two-factor authentication to new and existing Filament applications.
Learn More
Filament Two-Factor Authentication Demo — Filament Daily
Installation
Below, you'll find documentation on installing this plugin. If you have any questions, find a bug, need support, or have a feature request, please don't hesitate to reach out to me at stephenjudesuccess@gmail.com.
You can install the package via composer:
composer require stephenjude/filament-two-factor-authentication
Add the TwoFactorAuthenticatable trait to your application's authentication model and implement the HasPasskeys trait:
namespace App\Models; use Spatie\LaravelPasskeys\Models\Concerns\HasPasskeys; use Stephenjude\FilamentTwoFactorAuthentication\TwoFactorAuthenticatable; //... class User extends Authenticatable implements FilamentUser, HasPasskeys { use TwoFactorAuthenticatable; //...
⚠️ Passkey implementation is using the spatie/laravel-passkeys package under the hood.
Install the plugin migration using:
php artisan filament-two-factor-authentication:install
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-two-factor-authentication-views"
Plugin Configuration
Add two-factor authentication plugin to a panel by instantiating the plugin class and passing it to the plugin() method of the configuration:
... use Stephenjude\FilamentTwoFactorAuthentication\TwoFactorAuthenticationPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ TwoFactorAuthenticationPlugin::make() ->enableTwoFactorAuthentication() // Enable Google 2FA ->enablePasskeyAuthentication() // Enable Passkey ->addTwoFactorMenuItem() // Add 2FA menu item ->forceTwoFactorSetup() // Force 2FA setup ]) } ...
Advanced Configurations
use Stephenjude\FilamentTwoFactorAuthentication\TwoFactorAuthenticationPlugin; use Stephenjude\FilamentTwoFactorAuthentication\Middleware\ForceTwoFactorSetup; use Stephenjude\FilamentTwoFactorAuthentication\Middleware\TwoFactorChallenge; TwoFactorAuthenticationPlugin::make() ->enableTwoFactorAuthentication( condition: true, // Enable Google 2FA challengeMiddleware: TwoFactorChallenge::class, // Middleware to challenge user with 2FA ) ->enablePasskeyAuthentication( condition: true, // Enable Passkey ) ->forceTwoFactorSetup( condition: true, // Force 2FA setup for all users requiresPassword: true, // Require password during setup forceMiddleware: ForceTwoFactorSetup::class, // Middleware to enforce 2FA ) ->addTwoFactorMenuItem( condition: true, // Show 2FA on the user menu item label: '2FA', // Menu item label icon: 'heroicon-s-key', // Menu item icon ) ])
Custom Settings Page
If your application already has a user profile page, you can add a 2FA settings to your profile page view:
<x-filament-panels::page>
@livewire(\Stephenjude\FilamentTwoFactorAuthentication\Livewire\TwoFactorAuthentication::class)
@livewire(\Stephenjude\FilamentTwoFactorAuthentication\Livewire\PasskeyAuthentication::class)
</x-filament-panels::page>
Events
This package dispatches events which your application can subscribe to. You can listen to these events inside your EventServiceProvider class:
use Stephenjude\FilamentTwoFactorAuthentication\Events\{RecoveryCodeReplaced,RecoveryCodesGenerated,TwoFactorAuthenticationChallenged,TwoFactorAuthenticationConfirmed,TwoFactorAuthenticationDisabled,TwoFactorAuthenticationEnabled,TwoFactorAuthenticationFailed,ValidTwoFactorAuthenticationCodeProvided}; protected $listen = [ TwoFactorAuthenticationChallenged::class => [ // Dispatched when a user is required to enter 2FA code during login. ], TwoFactorAuthenticationFailed::class => [ // Dispatched when a user provides incorrect 2FA code or recovery code during login. ], ValidTwoFactorAuthenticationCodeProvided::class => [ // Dispatched when a user provides a valid 2FA code during login. ] TwoFactorAuthenticationConfirmed::class => [ // Dispatched when a user confirms code during 2FA setup. ], TwoFactorAuthenticationEnabled::class => [ // Dispatched when a user enables 2FA. ], TwoFactorAuthenticationDisabled::class => [ // Dispatched when a user disables 2FA. ], RecoveryCodeReplaced::class => [ // Dispatched after a user's recovery code is replaced. ], RecoveryCodesGenerated::class => [ // Dispatched after a user's recovery codes are generated. ], ];
Screenshot
2FA Authentication
2FA Recovery
2FA Disabled
2FA Setup
2FA Enabled (Recovery Codes)
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
stephenjude/filament-two-factor-authentication 适用场景与选型建议
stephenjude/filament-two-factor-authentication 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 211.39k 次下载、GitHub Stars 达 84, 最近一次更新时间为 2024 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「2fa」 「Two-factor Authentication」 「stephenjude」 「filament」 「passkey authentication」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stephenjude/filament-two-factor-authentication 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stephenjude/filament-two-factor-authentication 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stephenjude/filament-two-factor-authentication 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Filament Two Factor Authentication: Google 2FA + Passkey Authentication
Laravel Authentication package with built-in two-factor (Authy) and social authentication (Socialite).
This package provides Laravel bindings and a Eloquent/Model trait for pragmarx/recovery package.
Novactive eZ 2FA Bundle is an Ibexa bundle that provides two-factor authentication for your Ibexa project
Two-factor Authentication for WordPress
A stylish PHP application framework crafted using Slim, Twig, Eloquent and Sentinel designed to get you from clone to production in a matter of minutes.
统计信息
- 总下载量: 211.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 84
- 点击次数: 33
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-24





