/Twilioauth

Twilio 2 factor authentication using sms.

Primary LanguageRuby

About

Simple 2 factor authentication with Twilio sms.

Usage

require "twilioauth"
pin = Twilioauth.auth("+15555555555", :account_sid => "*************", :auth_token => "****************")

Simple example with controller methods.

def login
  #login has succeeded and now need to check pin
  session[:pin] = Twilioauth.auth(@user.phone, :account_sid => "**********", :auth_token => "**********")
  session[:pendinguser] = {name: params[:name], password: params[:password]}
  redirect_to "/auth"
end

def auth
  #form to enter pin here and submits to check_auth
  unless session[:pendinguser]
    redirect_to "/login"
  end
end

def check_auth
  #if the pin is the same set the user session
  if params[:pin] == session[:pin]
    session[:user] = session[:pendinguser]
    redirect_to "/success"
  else
    redirect_to "/login?pin_failed=true"
  end
end

TODO

Roll twilioauth into a rails engine with controllers and forms to handle everything for the developer.

History

0.0.5 removed a lot of unnecessary random charcter code.

0.0.4 first working version for rails integration

0.0.1 first working sms auth.