❗ This tutorial is no longer maintained, please see the updated version
Use Authy to add Two Factor Auth to your Rails app.
Create a free Twilio account, if you don't have one already, and then connect it to your Twilio account.
This project is built using the Ruby on Rails web framework.
-
First clone this repository and
cd
into it.$ git clone git@github.com:TwilioDevEd/authy2fa-rails.git $ cd authy2fa-rails
-
Install the dependencies.
$ bundle install
-
Export the environment variables.
You can find your Authy Api Key for your application at https://www.twilio.com/console/authy.
$ export AUTHY_API_KEY=Your Authy API Key
-
Create a SQLite3 database and run migrations.
$ bundle exec rake db:setup
-
Make sure the tests succeed.
$ bundle exec rake test
-
Run the server.
$ bundle exec rails s
-
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
-
Go to your Console and create a new application. In the menu to the you'll find the Push Authentication. Look for Webhooks 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 Endpoint/URL should look like this:
http://[your-domain].com/authy/callback
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.