Giter Site home page Giter Site logo

stevet3ch / authy2fa-flask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twiliodeved/authy2fa-flask

0.0 2.0 0.0 1.3 MB

2FA Implementation with Authy and Python Flask

Home Page: https://www.twilio.com/docs/tutorials/walkthrough/two-factor-authentication/python/flask

License: MIT License

Python 68.67% Mako 1.39% CSS 3.19% JavaScript 3.92% HTML 22.83%

authy2fa-flask's Introduction

Two-Factor Authentication with Authy OneTouch

This application example demonstrates how to implement Two-Factor Authentication on a Python Flask application using Authy OneTouch.

Build Status

Learn more about this code in our interactive code walkthrough.

Quickstart

Create an Authy app

Create a free Authy account if you haven't already done so and then connect it to your Twilio account.

Create a new Authy application. Be sure to set the OneTouch callback endpoint to http://your-server-here.com/authy/callback once you've finished configuring the app.

Deploying on Heroku

To get it up and running quickly, you can deploy this app for free using Heroku:

Deploy

Local development

This project is built using the Flask web framework. For now it only runs on Python 2.7 (not 3.4+).

  1. To run the app locally, first clone this repository and cd into it.

  2. Create a new virtual environment.

  3. Install the requirements.

    pip install -r requirements.txt
    
  4. Copy the .env_example file to .env, and edit it to include your Authy API key

  5. Run source .env to apply the environment variables (or even better, use autoenv)

  6. Start a local PostgreSQL database and create a database called 2fa_flask.

    • If on a Mac, we recommend using Postgres.app. After installing it, open psql and run CREATE DATABASE 2fa_flask;

    • If Postgres is already installed locally, you can just run createdb 2fa_flask from a terminal

  7. Run the migrations.

    python manage.py db upgrade
    
  8. Start the development server.

    python manage.py runserver
    

To actually process OneTouch authentication requests, your development server will need to be publicly accessible. We recommend using ngrok to solve this problem.

Once you have started ngrok, set your Authy app's OneTouch callback URL to use your ngrok hostname, like this:

http://88b37ada.ngrok.io/authy/callback

Run the tests

You can run the tests locally through coverage:

  1. Optionally create a separate test database and update your DATABASE_URL environment variable if you don't want your development data overwritten.

  2. Run the tests.

    $ coverage run manage.py test
    

You can then view the results with coverage report or build an HTML report with coverage html.

That's it!

Meta

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

authy2fa-flask's People

Contributors

acamino avatar atbaker avatar gregbaugues avatar jarodreyes avatar kathyguerron avatar kwhinnery avatar mattmakai avatar mcelicalderon avatar ronualdo avatar shyba 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.