Giter Club home page Giter Club logo

authy2fa-laravel's Introduction

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.

authy2fa-laravel's People

Contributors

acamino avatar dependabot-preview[bot] avatar dprothero avatar eliux avatar gregbaugues avatar jarodreyes avatar jefflinwood avatar kwhinnery avatar maylonpedroso avatar mcelicalderon avatar pkamp3 avatar rickyrobinett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

authy2fa-laravel's Issues

Different .env model than the tutorial

The repo and README use .env.example and this format:

APP_ENV=local
APP_DEBUG=true
APP_KEY=

DB_HOST=localhost
DB_DATABASE=authy2fa_laravel
DB_USERNAME=
DB_PASSWORD=

AUTHY_API_KEY=

The tutorial has:

<?php

return array(

    'APP_DEBUG' => true,
    'AUTHY_TOKEN' => getenv('AUTHY_TOKEN') || 'your authy key here',

);

Empty API response

I get empty API response after creating user and entering login details.

VM707:1 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at Object.success (sessions.js:11)
at j (jquery.js:3094)
at Object.fireWith [as resolveWith] (jquery.js:3206)
at x (jquery.js:8259)
at XMLHttpRequest. (jquery.js:8600)

When I console.log API response, data is empty.
sessions.js line 11 is ' var data = JSON.parse(data.replace(/1/g, "")); ', it cant parse empty value from API request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.