All Projects → TwilioDevEd → authy2fa-laravel

TwilioDevEd / authy2fa-laravel

Licence: other
2FA Implementation with Authy and Laravel (PHP)

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects
Blade
752 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects
Less
1899 projects
CSS
56736 projects

Two-Factor Authentication with Laravel and Authy

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.

Run the Application

  1. Clone the repository and cd into it.

  2. Install the application dependencies with Composer

    $ composer install
  3. 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.

  4. Create a database.

    $ createdb authy_laravel
  5. 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://www.twilio.com/console/authy/.

  6. Generating an APP_KEY:

    $ php artisan key:generate
  7. Running the migrations:

    $ php artisan migrate
  8. 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

  9. Running the application using Artisan.

    $ php artisan serve
  10. Go to https://www.twilio.com/console/authy/. 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 production, the the Endpoint/URL should look like this:

    http://[your-domain].com/authy/callback

Run the tests

  1. Download phpunit version 4

    $ wget https://phar.phpunit.de/phpunit-4.0.9.phar -O phpunit.phar
  2. Run phpunit

    $ php phpunit.phar

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].