Devise RPX Connectable
Devise << RPX by Nicolas Blanco
What is Devise?
A great authentication gem for Rails applications.
What is RPX?
RPX is a Software as a Service (SaaS) that helps you manage multiple authentication methods (FacebookConnect, Google, Twitter, OpenID, MySpace…) using a single API.
It also provides a multilingual connection widget.
Instead of managing multiple authentication providers and APIs, you just need to handle one.
RPX provides free and paid accounts.
See RPX official homepage. If you want to see what it looks like, you may signup on the RPX website as it uses RPX for signup :).
What is Devise RPX Connectable?
Devise RPX Connectable is a gem to integrate RPX authentication in a Rails application using Devise.
Please note that this is an unofficial library. It is neither affiliated with, nor endorsed by RPX/JanRain Inc.
Devise RPX Connectable was tested using latest stable Rails and Devise gems.
Rails : version 2.3.5
Devise : version 1.0.6
I also want it to be compatible with latest prerelease gems of Devise, Rails and Mongoid.
Therefore I also tested it with :
Rails : version 3.0.0beta3
Mongoid : version 2.0.0beta4
Devise : master branch.
Gem (Rails >= 2.3.5)
$ sudo gem install devise_rpx_connectable
config.gem 'devise' config.gem 'rpx_now' config.gem 'devise_rpx_connectable'
Gem (Rails >= 3.0.0beta3)
gem 'devise', :git => 'git://github.com/plataformatec/devise.git' gem 'rpx_now' gem 'devise_rpx_connectable'
See Devise documentation for instructions on how to setup Devise.
:rpx_connectable in your Devise model (ie. User.rb)
devise ..., :rpx_connectable
In the Devise initializer (may be
Devise.setup do |config| ... config.rpx_application_name = "mytestingapp" # The name of your RPX application (this is the name, NOT the API key!) end
... config.after_initialize do # so rake gems:install works RPXNow.api_key = "aaaabbbbbccccdddddeeeeefffff" end ...
Your model needs one attribute/column to store the RPX identifier. By default, this identifier is
The RPX connection widget can be added in your application using a link or an iframe.
I added an easy to use helper to add a link to the RPX connection popup.
<%= link_to_rpx "Signin using RPX!", user_session_url %>
If you use the link alone, users will be redirected to a new page.
If you want the more sexy popup in overlay, you need to add the JS code before the
</body> of your layout.
An helper is also included for this task :
If you want to display the connection widget in an iframe inside a page :
<%= embed_rpx user_session_url %>
There is some advanced features that you may use…
Devise.setup do |config| ... config.rpx_auto_create_account = true # false if you don't want to create users automaticaly. True by default. config.rpx_additional_user_data = [:verifiedEmail, :url, :providerName,:photo] #default , get some extra profile info from RPXnow, default only a few fields are available in the rpx_user object (https://rpxnow.com/docs#profile_data) config.rpx_extended_user_data = true #false by default, extended data only available for premium users (https://rpxnow.com/docs#api_auth_info) end
Some hooks are available to get the RPXNow user data objects before or after the connection. Read the RPXNow gem documentation for more information.
def before_rpx_connect(rpx_user) # Do something with rpx_user... end def after_rpx_connect(rpx_user) # Do something with rpx_user end
- With Rails 3 (only) I get an invalid auth token in sessions#create action. I have to skip the validation of the auth token. See why?
- Handle RPX multiple accounts mapping?
Released under the MIT license.
Copyright © 2010 Nicolas Blanco