Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament3 2Fa Laravel Package

lunarphp/filament3-2fa

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Filament 3 Compatibility: The package is explicitly designed for Filament 3, a modern Laravel admin panel framework. If the application already uses Filament 3, this package integrates seamlessly into the existing UI/UX flow (e.g., user profile management, authentication panels).
  • Laravel Ecosystem Alignment: Leverages Laravel’s native features (e.g., Hash, Encryption, Auth) and Filament’s widget system, reducing architectural friction.
  • Modularity: Supports Google Authenticator (TOTP) and Passkeys (WebAuthn), allowing phased adoption based on security requirements.

Integration Feasibility

  • Low-Coupling Design: Uses Filament’s resource/spy system to inject 2FA flows without modifying core authentication logic.
  • Database Schema: Requires minimal schema changes (e.g., two_factor_backups, passkey_credentials tables), which can be scaffolded via migrations.
  • Dependency Conflicts: Minimal risk if using Laravel 10+ and Filament 3.x; potential conflicts with older versions or custom auth systems.

Technical Risk

  • Passkey Support: WebAuthn (Passkeys) requires HTTPS and browser compatibility checks (e.g., Chrome/Edge/Safari). May need polyfills for legacy browsers.
  • TOTP Fallback: If Passkeys fail (e.g., unsupported devices), TOTP must remain robust. Backup codes should be enforced.
  • Rate Limiting: 2FA flows (e.g., TOTP scans, Passkey attempts) may need rate-limiting to prevent brute-force attacks.
  • Testing Gaps: No dependents or stars suggest unproven real-world use; load testing for Passkey enrollment/verification is critical.

Key Questions

  1. Authentication Flow: How will 2FA be triggered (e.g., login, profile update)? Will it be mandatory or optional?
  2. User Experience: Should Passkeys be the primary method, with TOTP as a fallback, or vice versa?
  3. Backup Codes: How will backup codes be stored/recovered (e.g., encrypted in DB, user-managed)?
  4. Multi-Tenancy: If the app supports multiple tenants, will 2FA policies be tenant-specific?
  5. Audit Logging: Are there requirements to log 2FA events (e.g., failed attempts, Passkey registrations)?
  6. Fallback Mechanisms: What happens if both Passkeys and TOTP fail (e.g., device loss)?

Integration Approach

Stack Fit

  • Laravel 10+: Required for Filament 3 and WebAuthn (Passkey) support.
  • Filament 3.x: Native integration via Filament’s Panel, Resources, and Widgets.
  • Database: Supports MySQL/PostgreSQL/SQLite; migrations provided for 2FA tables.
  • Frontend: Works with Filament’s Blade/Inertia/Vue templates; Passkeys require modern browsers.

Migration Path

  1. Pre-Integration:
    • Audit existing auth flow (e.g., LoginController, Fortify/Breeze).
    • Ensure HTTPS is enforced (required for Passkeys).
    • Backup user data in case of migration issues.
  2. Installation:
    composer require lunarphp/filament3-2fa
    php artisan vendor:publish --provider="Lunar\Filament2FA\Filament2FAServiceProvider"
    php artisan migrate
    
    • Publish config (config/filament2fa.php) to customize:
      • Enabled methods (TOTP/Passkey).
      • Backup code settings.
      • Rate limits.
  3. Configuration:
    • Register the 2FA widget in app/Providers/Filament/AdminPanelProvider.php:
      public function panel(Panel $panel): Panel
      {
          return $panel
              ->widgets([
                  \Lunar\Filament2FA\Widgets\TwoFactorAuthenticationWidget::class,
              ]);
      }
      
    • Extend user model to include 2FA traits (if not auto-injected).
  4. Testing:
    • Unit Tests: Verify TOTP generation/validation.
    • E2E Tests: Test Passkey enrollment/verification in staging.
    • Fallback Testing: Simulate Passkey failure and ensure TOTP works.

Compatibility

  • Filament Plugins: May conflict with other auth-related plugins (e.g., spatie/laravel-permission). Test in isolation.
  • Custom Auth: If using non-Filament auth (e.g., Laravel Sanctum), adapt middleware to redirect to Filament’s 2FA flow.
  • Legacy Browsers: Passkeys require WebAuthn API; provide TOTP as a fallback for unsupported devices.

Sequencing

  1. Phase 1: Implement TOTP-only for broad compatibility.
  2. Phase 2: Add Passkeys for users with supported devices/browsers.
  3. Phase 3: Enforce 2FA for admin/privileged roles.
  4. Phase 4: Deprecate legacy auth methods (e.g., SMS-based 2FA if used).

Operational Impact

Maintenance

  • Updates: Monitor for Filament 3.x breaking changes; package may need forks if upstream updates.
  • Backup Codes: Rotate backup codes periodically (e.g., via a Filament cron job).
  • Passkey Revocation: Implement a mechanism to revoke compromised Passkeys (e.g., via WebAuthn credential ID).

Support

  • User Onboarding: Provide clear docs/FAQs for:
    • TOTP setup (QR code scanning).
    • Passkey enrollment (device compatibility).
    • Backup code storage (secure offline storage).
  • Troubleshooting: Log common issues (e.g., "Passkey not detected") and create a knowledge base.
  • Support Channels: Ensure Filament/Passkey-specific support is available (e.g., Slack community).

Scaling

  • Performance:
    • TOTP: Stateless; minimal DB load.
    • Passkeys: WebAuthn challenges may add latency (~100–300ms per request). Cache PublicKeyCredential responses.
  • Database: 2FA tables (two_factor_backups, passkey_credentials) are small; no scaling concerns.
  • Rate Limiting: Implement throttle middleware for 2FA endpoints to prevent abuse.

Failure Modes

Failure Scenario Impact Mitigation
Passkey enrollment fails Users stuck without 2FA Fallback to TOTP; log errors for debugging.
TOTP secret loss User locked out Backup codes + admin recovery flow.
Database corruption 2FA state lost Regular backups; use transactions for writes.
WebAuthn server misconfig Passkeys rejected Validate WebAuthn config with webauthn.io.
High 2FA failure rates User frustration Rate-limiting + CAPTCHA for repeated failures.

Ramp-Up

  • Team Training:
    • Developers: Focus on Filament widget integration and WebAuthn basics.
    • DevOps: Ensure HTTPS, CORS, and WebAuthn server config are correct.
    • Security: Review backup code storage and rotation policies.
  • User Training:
    • Admin Users: Mandatory 2FA training (e.g., video walkthroughs).
    • End Users: In-app tooltips for TOTP/Passkey setup.
  • Pilot Program:
    • Roll out to a small user group (e.g., 10% of admins) before full release.
    • Gather feedback on UX pain points (e.g., Passkey enrollment steps).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope