PHPackages                             jrebs/rapid2fa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. jrebs/rapid2fa

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

jrebs/rapid2fa
==============

Seamlessly add Google2FA support to Laravel Auth

043PHP

Since Mar 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jrebs/rapid2fa)[ Packagist](https://packagist.org/packages/jrebs/rapid2fa)[ RSS](/packages/jrebs-rapid2fa/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Rapid2FA Package for Laravel
============================

[](#rapid2fa-package-for-laravel)

❗ **This package is no longer maintained. Its functionality has been superceded by laravel's jetstream package in newer versions of laravel. It will remain up for a while to satisfy a few straggler projects that are still depending on it, but expect it to be officially archived at some point, probably by or during 2022.**

Wanting to learn how packaging for Laravel works and after integrating two-factor authentication for a project at work, I made a little weekend project of building this zero-effort two-factor package for apps using Laravel with the core auth system.

Strictly speaking, I've more or less accomplished my goal of a zero setup install. To make the feature useful to your users, of course, you need to put an element somewhere, but I've provided a drop-in blade fragment you can copy or use as a guide to make your own.

Requirements
------------

[](#requirements)

- `php >= 7.2`
- `laravel/framework >= 6`
- `google2fa-laravel`

This package is intended for use in apps using basic Laravel Auth support and could pose problems alongside other packages or app customizations which modify the normal handling of the `App\Http\Controllers\Auth\LoginController`methods.

Installation
------------

[](#installation)

All of the migrations, routes and views are sourced at runtime dynamically so no publishing is required, just install and run the migration(s).

```
composer require jrebs/rapid2fa
php artisan migrate

```

You can override all config settings with environmental vars, but if you want to override the default values used by the config you can publish the config file to your application's config folder and then modify.

```
php artisan vendor:publish --provider=Jrebs\\Rapid2FA\\Providers\\Rapid2FAServiceProvider
```

It's not required, but for safety, I recommend adding `google2fa_secret` to your `App\User::$hidden` array. This will tell Eloquent not to include this field when serializing objects, such as in the case of JSON responses.

Configuration
-------------

[](#configuration)

You can define environmental variables to prevent this package from overloading your application's `/login` routes as well as define custom strings to use for validation errors and other small feedback responses.

configenvtypeeffect`rapid2fa.app_login_form``RAPID2FA_APP_LOGIN_FORM``bool`Set true to allow the app to route the login form render`rapid2fa.app_login_post``RAPID2FA_APP_LOGIN_POST``bool`Set true to allow the app to route the login handler`rapid2fa.failed_text``RAPID2FA_STR_FAILED``string`Overrides the default validation message returned on two-factor failure`rapid2fa.enabled_text``RAPID2FA_STR_ENABLED``string`Override the default two-factor enabled notice`rapid2fa.disabled_text``RAPID2FA_STR_ENABLED``string`Override the default two-factor disabled notice`rapid2fa.denied_text``RAPID2FA_STR_DENIED``string`Override the default message when a user redirected because of `require2fa` middlewareUsage
-----

[](#usage)

It's ready to use. All you need is to offer your users a way to enable or disable two-factor. Either include this fragment into a view template or come up with your own display method.

```
@include('rapid2fa::toggle')
```

Middleware
----------

[](#middleware)

A simple middleware layer is available so that you can require a user to be using two-factor authentication to be able to access particular routes.

```
Route::middleware(['requires2fa'])->get('/personal', function () {
    // this stuff is extra secret!
});
```

Customization
-------------

[](#customization)

This package provides a login form view and a basic view for showing QR codes to enable two-factor. To modify these views for your application, copy to `resources/views/vendor/rapid2fa` and then season to taste.

TODO
----

[](#todo)

- Make configurable text strings translatable
- Possibly refactor to downgrade dependence from `google2fa-laravel` to just `google2fa`.

Thanks
------

[](#thanks)

This package is merely a connector for a bunch of pre-existing functionality which was graciously made available to us all. Thanks are due to many, but especially to Taylor Otwell for Laravel and Antonio Ribeiro for Google2FA.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7be6aa129cd8860ec177bd2820612c277dd9a80c904a8e814c46fdccdca2e6fa?d=identicon)[jrebs](/maintainers/jrebs)

---

Top Contributors

[![jrebs](https://avatars.githubusercontent.com/u/4203789?v=4)](https://github.com/jrebs "jrebs (20 commits)")

### Embed Badge

![Health badge](/badges/jrebs-rapid2fa/health.svg)

```
[![Health](https://phpackages.com/badges/jrebs-rapid2fa/health.svg)](https://phpackages.com/packages/jrebs-rapid2fa)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
