Skip to content

Nexmo/ruby-2fa

Repository files navigation

Two Factor Authentication with Nexmo Verify

A Rails (Ruby) app showing how to implement two-factor authentication using the Nexmo Verify API.

Prerequisites

Getting started

# clone this repository
git clone [email protected]:Nexmo/ruby-2fa.git
# change to folder
cd ruby-2fa
# install dependencies
bundle install
# create a .env
cp .env.example .env

Next you will need to sign up for a Nexmo account and get your API credentials from the API dashboard and put them in your .env file.

Finally all that's left is to start the server.

rails server

Usage

This app shows you how to secure your app login with two-factor authentication using Rails, Ruby and Nexmo Verify.

Once your server is started:

  • Visit localhost:3000
  • Register for an account
    • The phone number must be provided without any leading 0's or +'s (e.g. 445555666777)
  • You will receive a code in a few seconds, fill this in on the second form and submit
  • You will now be registered and logged in
  • Logout and in again to see the same in action for login

License

This project is licensed under the MIT license.