In this example application, you will learn how to create a login system for Laravel applications secured with 2FA using Authy.
Learn more about this code in our interactive code walkthrough.
-
Clone the repository and
cd
into it. -
Install the application dependencies with Composer
$ composer install
-
The application uses PostgreSQL as persistence layer. If you don't have it already, you should install it. The easiest way is by using Postgres.app.
-
Create a database.
$ createdb authy_laravel
-
Copy the sample configuration file and edit it to match your configuration.
$ cp .env.example .env
You can find your Authy Api Key for Production at https://dashboard.authy.com/.
-
Generating an
APP_KEY
:$ php artisan key:generate
-
Running the migrations:
$ php artisan migrate
-
Expose your application to the wider internet using ngrok. You can look here for more details. This step is important because the application won't work as expected if you run it through the localhost.
$ ngrok http 8000
Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this:
http://9a159ccf.ngrok.io
-
Running the application using Artisan.
$ php artisan serve
-
Go to your https://dashboard.authy.com. On the menu to the right you'll find the Settings. Go to OneTouch settings and update the Endpoint/URL with the endpoint you created. Something like this:
http://[your-ngrok-subdomain].ngrok.io/authy/callback
If you deployed this application to Heroku, the the Endpoint/URL should look like this:
http://[your-heroku-subdomain].herokuapp.com/authy/callback
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.