scheb/2fa-bundle, a well-established Laravel/Symfony 2FA solution, making it a natural fit for applications already using or planning to adopt the bundle. The email-based 2FA provider aligns with modern security best practices for user authentication.scheb/2fa-bundle (Symfony 5.4+ / Laravel 9+ via Symfony bridge) and a mail service (e.g., Symfony Mailer, SwiftMailer). Compatibility with Laravel is achievable via the symfony/mailer bridge or native Laravel Mail.config/bundles.php and configuring the email provider (SMTP/transport) in .env or Symfony/Laravel mail settings.scheb/2fa-bundle's existing user metadata storage (e.g., user_2fa table).symfony/mailer (Laravel 9+) to replace SwiftMailer.SchebTwoFactorBundle) to Laravel’s container.SchebTwoFactor\Event\TwoFactorCodeGeneratedEvent) to Laravel’s event system..env (e.g., MAIL_MAILER=smtp).scheb/2fa-bundle (via composer require scheb/two-factor-bundle).composer require danielburger1337/2fa-email
config/bundles.php (Laravel):
return [
// ...
Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true],
DanielBurger\TwoFactorEmailBundle\DanielBurgerTwoFactorEmailBundle::class => ['all' => true],
];
config/packages/scheb_two_factor.yaml:
scheb_two_factor:
email:
code_lifetime: 900 # 15 minutes in seconds
templates/scheb_two_factor/email/ (Symfony) or Laravel’s resources/views/vendor/scheb_two_factor/email/.ServiceProvider to alias Symfony services:
public function register()
{
$this->app->bind(
\Scheb\TwoFactorBundle\Security\TwoFactor\Provider\EmailProvider::class,
\DanielBurger\TwoFactorEmailBundle\Provider\EmailProvider::class
);
}
// Listen to Symfony's TwoFactorCodeGeneratedEvent in Laravel
event(new TwoFactorCodeGeneratedEvent($user, $code));
HttpTests or Symfony’s WebTestCase to verify 2FA flows, especially email delivery.scheb/2fa-bundle and test basic TOTP/SMS 2FA.danielburger1337/2fa-email and configure email provider.scheb/2fa-bundle and danielburger1337/2fa-email for breaking changes. The MIT license allows forks if needed.failed_jobs table or Symfony’s monolog). Alert on high failure rates.user_2fa table may grow with user base. Ensure indexes are optimized for 2FA checks.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Email transport failure (SMTP down) | Users locked out of 2FA | Fallback to SMS/TOTP or admin override. Alert on repeated failures. |
| Expired codes | User frustration | Auto-resend logic, clear UX for expiration. |
| Database corruption (2FA table) | 2FA data loss | Regular backups. Use transactions for 2FA updates. |
| High email volume | Queue backlog, timeouts | Queue emails, implement retries with exponential backoff. |
| Template rendering errors | Broken emails | Validate templates in CI. Use a fallback template if primary fails. |
scheb/2fa-email provider.How can I help you explore Laravel packages today?