PHPackages                             dcvn/otp-laravel - 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. dcvn/otp-laravel

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

dcvn/otp-laravel
================

Laravel layer for local OTP authentication

v1.0.0(7y ago)113MITPHP

Since Feb 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dcvn/otp-laravel)[ Packagist](https://packagist.org/packages/dcvn/otp-laravel)[ RSS](/packages/dcvn-otp-laravel/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

OneTimePassword (OTP) for Laravel
=================================

[](#onetimepassword-otp-for-laravel)

*A Laravel layer for local OTP authentication.*

This is an attempt to make OTP implementation in Laravel easy.

Being a **layer**, this could not exist without these core dependencies:

- the package [robthree/twofactorauth](https://github.com/RobThree/TwoFactorAuth)does the real OTP logic, and
- the included merged version of [phpqrcode](https://github.com/t0k4rt/phpqrcode)does the real QRCode generation.

Being **local**, otp-laravel does, by default, *not* depend on network services to generate QR codes *(with thanks to the offline example of RobThree using phpqrcode)*.

### Quickstart setup

[](#quickstart-setup)

Follow the [Quickstart](QUICKSTART.md)to setup a new Laravel project using this OTP package.

The most important part is, in the LoginController, to replace the existing *use AuthenticatesUsers*to `use Dcvn\Otp\Http\Controllers\AuthenticatesUsers;`.

If you feel real lazy, copy this [quickstart.sh script](scripts/quickstart.sh)to the base dir of your projects, and run it (at your own risk).

### Features

[](#features)

*Assuming using the quickstart way, but you can implement how you like it.*

- Adds an `otp_secret` column to the `users` table (migration).
- Adds an OTP input to the login page, and validates for it when it has been set up.
- Adds routes, controller methods and views for setting up OTP for a user.
- By default, you are only allowed to do the setup for your own user.
- Many settings are configurable by config and `.env`.
- Translations available in english and dutch.
- `OneTimePassword` as alias in the app.

#### OneTimePassword example

[](#onetimepassword-example)

```
