Authful Ruby Client
Makes integration with 2fa as simple as possible. This gem interacts with the open-sourced Authful service for 2fa.
Installation
Add this line to your application's Gemfile:
gem 'authful'
And then execute:
$ bundle
Or install it yourself as:
$ gem install authful
Usage
To use, you will need an Authful endpoint. You will need to install it, or if a successful project, you will probably find Authful endpoint as a service.
To configure the gem, use:
Authful.configure do |c|
c.endpoint = "https://<myendpoint>"
c.api_key = "<my api key>"
end
res = Authful.enroll("[email protected]")
res.qr_code # use this to display the QR code for the user signup
res.token # You will want to save this token to your application, it is
# the user's primary key to the authful service. It is **not**
# the secret token used to generate OTP.
Authful.set_phone("token", "12005551212") # sets the users phone number
Authful.send_sms("token") # sends sms token
Authful.validate("token", "000000") # validates OTP token
res = Authful.reset("token") # Resets the users secret
res.qr_code # use this to display the new QR code for the user
Authful.unenroll("token") # Remove user from Authful service
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request