A Devise extension to allow your app to utilise Google's 2FA Mobile app
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
This project is no longer maintained.
If you have a more recent fork and you'd like us to link to it from here, please get in touch.
= Devise Google Authenticator
This is a devise[https://github.com/plataformatec/devise] extension to allow your app to utilise Google Authenticator[http://code.google.com/p/google-authenticator/] for Time-based One Time Passwords (TOTP).
Add the gem to your Gemfile (don't forget devise too):
Don't forget to "bundle install"
=== Devise Installation (In case you haven't done it)
Before you can setup Devise Google Authenticator you need to setup Devise first, you need to do the following (but refer to https://github.com/plataformatec/devise for more information)
Install Devise: * rails g devise:install
Setup the User or Admin model * rails g devise MODEL
Configure your app for authorisation, edit your Controller and add this before_filter:
Make sure your "root" route is configured in config/routes.rb
=== Automatic Installation (Lets assume this is a bare bones app)
Run the following generator to add the necessary configuration options to Devise's config file:
After you've created your Devise user models (which is usually done with a "rails g devise MODEL"), set up your Google Authenticator additions:
Don't forget to migrate if you're NOT using Mongoid as your database ORM, Mongoid installations will have appropriate fields added to the model after the command above:
=== Installation With Existing Users
After the above steps have been performed, you'll need to generate secrets for each user: User.where(:gauthsecret => nil).findeach do |user| user.send(:assignauthsecret) user.save! end By default, users won't need to perform two-factor authentication (gauthenabled='f'). By visiting /MODEL/displayqr (eg: /users/displayqr) and submitting the form, two-factor authentication will then be turned on (gauthenabled=1) and required for subsequent logins.
== Configuration Options
The install generator adds some options to the end of your Devise config file (config/initializers/devise.rb)
== Custom Views
If you want to customise your views (which you likely will want to, as they're pretty ugly right now), you can use the generator:
With this extension enabled, the following is expected behaviour:
The install generator also installs an english copy of a Devise Google Authenticator i18n file. This can be modified (or used to create other language versions) and is located at: config/locales/devise.google_authenticator.en.yml
== Changes * Version 0.3.16 - A few bug-fixes. Test-cases are now passing in Ruby 1.9.3 and 2.1.5 * Version 0.3.15 - Can now configure whether the displayqr page is displayed during sign-up. Can customise the app's name (thanks Felipe Lima). Require the users to enter the token when enabling or disabling the token (thanks again Felipe Lima). Handle namespaced Devise models (thanks Mikkel Garcia). Ability to set an Issuer within the OTP generation (thanks Sylvain UTARD). * Version 0.3.14 - Users can now generate a new token if they wish. This is available from the displayqr page. * Version 0.3.13 - Merged a feature to allow a qualifier for the Google Authenticator token display. This allows you to specify in your view a qualifier for the name of the OTP when it's enrolled into the Google Authenticator app. Thanks Michael Guymon for the pull. * Version 0.3.12 - Re-introduced Warden's afterauthentication callback. Thanks Sunny Ng for the pull. * Version 0.3.11 - Fixed a bug where if the Devise module was included within something else, such as Active Admin, rewriting back to the CheckGA functionality was broken. This update addresses https://github.com/AsteriskLabs/devisegoogle_authenticator/issues/7 * Version 0.3.10 - Added support for Mongoid ORM in addition to ActiveRecord. (Still no appropriate testing for, but I've run this on vanilla Rails 4.0.4 and Devise 3.2.3 apps) * Version 0.3.9 - Merging fix from zhenyuchen (deprecated ActiveRecord query grammar) - also, re-tested against Rails 4.0.4 and Devise 3.2.3 * Version 0.3.8 - Support for remembering the token authentication. (i.e. don't request the token for a configurable amount of time Thanks https://github.com/blahblahblah-) - and seriously, I'm going to try and refactor all the integration tests with Rspec. * Version 0.3.7 - Support for current Devise (3.2.0) and Rails4 (Thanks https://github.com/ronald05arias) - integration test still broke - need to address this * Version 0.3.6 - Slight updates - increased key size, more open gemspec, updated en.yml. (Thanks Michael Guymon) * Version 0.3.5 - Updated README for Rails apps with existing users. (Thanks Jon Collier) * Version 0.3.4 - Updated test cases to function properly, and tested working with Devise 2.2 (up to at least Devise 2.2.4) * Version 0.3.3 - Updated some of the redirect methods to proper align with Devise 2.1.0. Also tidied up some of the test routines to proper replicate Devise 2.1.0 * Version 0.3.2 - Updated to include support for Devise 2.0.0 and above (no longer supports 1.5.3 or lower), you'll need version 0.3.1 to use older Devise * Version 0.3.1 - Slight updated in the dependencies. * Version 0.3 - first working version! With working generators, tests, and doesnt require changes to Devise's Sign In view * Version 0.2 - tidied up some of the code - changed the references to AsteriskLabs * Version 0.1 - initial release, just to push it up, is still very early and requires a bit work
== Thanks (and unknown contributors)
This extension would not exist without the following other projects and associated authors (Whom I have turned to for inspiration and definitely have helped contributing by providing awesome Devise extensions. A lot of this code has been refactored from various sources, in particular these - in particular Sergio and Devise_invitable for his excellent unit test code):
== Contributing to devisegoogleauthenticator
Copyright (c) 2014 Christian Frichot. See LICENSE.txt for further details.