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
Google2Fa Laravel

Google2Fa Laravel Laravel Package

jc5/google2fa-laravel

jc5/google2fa-laravel adds Google Two-Factor Authentication to Laravel applications. Generate secrets and QR codes, verify TOTP one-time codes, and protect user logins with a simple, framework-friendly API.

Deep Wiki
Context7

jc5/google2fa-laravel adds Google Authenticator-compatible two-factor authentication to Laravel applications. It provides Laravel-friendly configuration and helpers for generating secrets, rendering QR codes, and verifying TOTP codes during authentication.

  • Generate and store per-user 2FA secrets
  • Render QR codes for authenticator apps
  • Verify time-based one-time passwords
  • Integrate verification into Laravel login flows
  • Configure settings through Laravel’s config system
Frequently asked questions about Google2Fa Laravel
How do I install jc5/google2fa-laravel in a Laravel app?
Install it with Composer using composer require jc5/google2fa-laravel. Laravel's package auto-discovery should register the service provider, but follow the package README for any required config publishing or middleware registration. Then add the provided trait to your authenticatable user model.
Which Laravel versions does jc5/google2fa-laravel support?
Supported Laravel versions are defined by the package's Composer constraints, so check its composer.json or Packagist metadata before upgrading. The package is designed for Laravel applications and integrates through a trait, middleware, and Blade helpers. If you are on an older or very new Laravel release, verify compatibility first.
How do I enable Google Authenticator 2FA on my User model?
Add the package's 2FA trait to your authenticatable User model and configure the relevant secret column or storage as described in the README. The trait provides the methods used to generate and verify one-time passwords. You then wire those methods into your login and verification controllers.
How do I generate a QR code for Google Authenticator?
The package includes QR code generation helpers so you can present an enrollment QR code for users to scan with Google Authenticator. Generate the user's secret, build the otpauth URI, and render it through the package's Blade helper or QR generator. Always show the secret manually as a fallback.
How does the middleware protect routes in this package?
The middleware checks whether the authenticated user has completed two-factor verification before allowing access to protected routes. Register it in your HTTP kernel or route group and redirect unverified users to your 2FA challenge page. Keep login, challenge, and logout routes outside the protected group.
How do recovery codes work with jc5/google2fa-laravel?
Recovery codes give users a one-time fallback when they cannot access their authenticator app. The package supports generating and validating recovery codes, and you should store them hashed and mark each code as used. Include a clear workflow for regenerating codes after they are exhausted.
Can I customize the 2FA verification flow and Blade views?
Yes, the package is described as supporting customizable verification flows and Blade helpers. You can adapt your challenge controller, routes, and views to match your application's login UX. Publish any package views or config if the README provides those commands, then override them safely.
How do I test Google Authenticator 2FA in Laravel?
Use Laravel's testing helpers to authenticate a user and assert that protected routes redirect until 2FA verification succeeds. Generate a known TOTP secret in the test and submit a valid code, or fake the verification layer if the package allows it. Also test recovery-code login and invalid-code handling.
Is jc5/google2fa-laravel safe for production use?
It provides the core building blocks for TOTP-based two-factor authentication, but production safety depends on correct secret storage, HTTPS, rate limiting, and recovery-code handling. Review the package source and README, keep dependencies updated, and test your enrollment and challenge flows. For high-security apps, consider a maintained alternative or additional controls.
What are alternatives to jc5/google2fa-laravel for Laravel 2FA?
Alternatives include pragmarx/google2fa with a QR code library, Laravel Fortify's two-factor authentication features, and other TOTP packages. Compare maintenance activity, Laravel version support, recovery-code support, and whether they provide middleware and Blade helpers. Choose based on your app's current Laravel version and long-term support needs.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
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