DeviseTouchpassable

TODO: Write a gem description

Usage

Add the following to your Gemfile:

gem 'devise_touchpassable'

Add your TouchPass API key to config/initializers/devise.rb:

# The API key of your TouchPass RP
config.touchpass_api_key = 'abcdef0123456789'

Add touchpass authentication to the list of modules on your User model:

devise :database_authenticable, :touchpassable

Add a touchpass username field to your User model:

$ rails generate migration add_touchpass_username_to_users touchpass_username:string
$ rake db:migrate

Add a before_filter after your :authenticate_user! filter to ensure your users are TouchPass validated after sign in.

class ApplicationController < ActionController::Base
  before_filter :authenticate_user!
  before_filter :touchpass_verify!
  ...
end

Customisation

The following additional configuration parameters are available, their defaults are shown below.

config.touchpass_hostname = 'https://touchpass.geodica.com'

# How frequently to refresh when waiting for verification (seconds)
config.touchpass_refresh_rate = 6

# How many attempts to make before giving up on verification
config.touchpass_refresh_attempts = 10

# The name of the attribute on your User model that contains the users
# TouchPass username
config.touchpass_username_attribute = 'touchpass_username'

You can additionaly implement the following methods on your user model to control behaviour, some examples are given below.

# Return false if you wish the user to skip TouchPass verification based
# on some properties.  Defaults to always true.
def need_touchpass_authentication?
  admin_user? and is_trusted?
end

# Customise the value of the users TouchPass username.  Defaults to the
# value of the attribute specified in config.touchpass_username_attribute
def touchpass_username
  User.lookup_touchpass_username_for(email)
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request