Weave 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
Twofactor Auth

Twofactor Auth Laravel Package

michaeldzjap/twofactor-auth

Lightweight Laravel package that adds two-factor authentication using TOTP codes compatible with Google Authenticator. Includes QR code provisioning, recovery codes, route middleware and events, making it straightforward to secure your application's login flow.

View on GitHub
Deep Wiki
Context7

michaeldzjap/twofactor-auth is a Laravel package that adds TOTP-based two-factor authentication to your application. It provides the building blocks for enrolling users, generating secrets, verifying one-time codes, and protecting routes with middleware.

  • TOTP verification compatible with authenticator apps
  • QR code provisioning for easy user enrollment
  • Route middleware for enforcing 2FA
  • Configurable Laravel integration and settings
  • Simple setup for existing authentication flows
Frequently asked questions about Twofactor Auth
What does michaeldzjap/twofactor-auth do?
It is a narrow Laravel package for adding a second authentication factor to an existing Laravel login flow. The package overview describes generating and verifying one-time codes from authenticator apps and issuing recovery codes. The technical evaluation also notes a MessageBird Verify-backed SMS OTP implementation, so confirm which flow the specific release provides before adopting it.
Which Laravel and PHP versions does this two-factor package support?
The package advertises support for Laravel 8 and newer, but you should verify its exact PHP and Laravel constraints against your application runtime and test matrix. The technical evaluation flags the package as archived, meaning there will be no future compatibility fixes for newer Laravel or PHP releases. Run Composer dependency checks and static analysis before assuming it fits your stack.
How do I install and configure michaeldzjap/twofactor-auth in a Laravel app?
Typical integration involves requiring the package with Composer, registering its service provider, publishing configuration and migrations, and running the migrations. You then wire the challenge routes or middleware into your existing authentication flow and configure any required provider credentials. Because the package is archived, treat the install as a fork-first dependency and pin the exact release you have reviewed.
Does it support authenticator apps and TOTP, or SMS OTP through MessageBird Verify?
The package blurb mentions one-time codes from authenticator apps and recovery codes, while the technical evaluation describes a MessageBird Verify-backed second factor for SMS OTP. Those are different operational and security models, so inspect the release code, configuration, and tests to confirm what is actually implemented. If you need TOTP or WebAuthn as a primary second factor, compare maintained alternatives before committing.
How are recovery codes handled by this Laravel two-factor package?
The overview says the package can issue recovery codes, which is important for account recovery when a second factor is unavailable. The technical evaluation raises open questions about enrollment, re-enrollment, admin reset, and audit logging around recovery. Validate how codes are generated, stored, invalidated, and rate-limited in the specific version you evaluate.
Is michaeldzjap/twofactor-auth safe to use in production?
Treat it as high risk for security-sensitive authentication code. The technical evaluation notes that the package is archived, has low community adoption, and has no upstream security patching or support. If you use it, fork the code internally, pin the release, add tests for replay and lockout paths, and obtain a security review before production use.
Can I use this package with API token auth, SPAs, or only session-based Laravel apps?
The best fit is a Laravel application using session-based or simple token authentication with a bounded user population. The technical evaluation lists compatibility with API guards, SPAs, and configurable challenge middleware as open questions rather than confirmed capabilities. Test the challenge routes and middleware against your actual auth guard, user provider, and session or token behavior.
How do I customize enrollment, reset, rate limiting, and audit logging around the package?
Most of that work sits outside the package itself: define enrollment and re-enrollment rules, admin reset procedures, recovery handling, audit events, rate limits, and exception paths in your application. The package can accelerate the OTP send and check step, but it is not a general-purpose identity or step-up authentication framework. Wrap provider calls in a thin adapter so you can change vendors or behavior without rewriting your auth flow.
What are maintained alternatives to this Laravel two-factor authentication package?
Consider Laravel Fortify with a custom OTP driver, a maintained verification SDK, or a direct integration with your chosen OTP provider. If you already use another OTP vendor, a thin adapter or reference implementation may be safer than migrating providers just to use this package. For stronger second factors, evaluate WebAuthn, passkeys, or TOTP solutions with active maintenance.
How should I migrate away from or fork michaeldzjap/twofactor-auth?
Vendor the code into an internal namespace, pin the exact release, add ownership metadata, and write tests for your application’s authentication flows. Confirm that migrations are reversible and do not conflict with existing phone or verification columns. If you are already on another OTP provider, use the package as a reference implementation rather than making it a long-term platform dependency.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo