Giter Club home page Giter Club logo

account-security-2fa-node's Introduction

Two-Factor Authentication with Node.js and Authy

Here you will learn how to create a login system for Express applications secured with 2FA using Authy.

Learn more about this code in our interactive code walkthrough.

Quickstart

Create an Authy app

Create a free Authy account if you don't have one already, and then connect it to your Twilio account.

Local development

This project is built using the Express web framework.

  1. First clone this repository and cd into it.

    $ git clone [email protected]:TwilioDevEd/authy2fa-node.git
    $ cd authy2fa-node
  2. Install the dependencies.

    $ npm install
  3. Make sure you have installed MongoDB. If on a Mac, you can use this guide to install it.

  4. Export the environment variables.

    You can find your Authy Api Key for Production at https://dashboard.authy.com/. The default MongoDB URL when running MongoDB locally is shown below.

    $ export AUTHY_API_KEY=Your Authy API Key
    $ export MONGO_URL=mongodb://127.0.0.1:27017
  5. Run the server.

    $ node .

    Alternatively you might also consider using nodemon for this. It works just like the node command, but automatically restarts your application when you change any source code files.

    $ npm install -g nodemon
    $ nodemon .
    
  6. Expose your application to the wider internet using ngrok. You can click here for more details. This step is important because the application won't work as expected if you run it through localhost.

$ ngrok http 3000

Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this: http://9a159ccf.ngrok.io

  1. 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 production, the the Endpoint/URL should look like this:

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

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

account-security-2fa-node's People

Contributors

acamino avatar dprothero avatar gregbaugues avatar jarodreyes avatar kathyguerron avatar kwhinnery avatar mcelicalderon avatar nebtrx avatar pkamp3 avatar

Watchers

 avatar  avatar

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.