Code Monkey home page Code Monkey logo

twofactorauth's Introduction

Two (2) Factor Authentication (2FA) Scala Code

2 Factor Authentication (2FA) Scala code which used the Time-based One-time Password (TOTP) algorithm. You can use this code with the Google Authenticator mobile app or the Authy mobile or browser app.

To get this to work you:

  1. Use generateBase32Secret() to generate a secret key in base-32 format for the user. For example: "NY4A5CPJZ46LXZCP"
  2. Store the secret key in the database associated with the user account.
  3. Display the QR image URL returned by qrImageUrl(...) to the user. Here's a sample which uses GoogleAPIs:
    Sample QR Image
  4. User uses the image to load the secret key into his authenticator application.

Whenever the user logs in:

  1. The user enters the number from the authenticator application into the login form on the web server.
  2. The web server reads the secret associated with the user account from the database.
  3. The server compares the user input with the output from generateCurrentNumberString(...).
  4. If they are equal then the user is allowed to log in.

twofactorauth's People

Contributors

bunyod 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.