Friday, February 6, 2009

RPX Now: Single Sign-on

As I write this, I'm trying to install the single sign-on capability that RPX Now gives you on my Rails app. I've tried OpenID before (using open_id_authentication plugin and ruby-openid gem) and it was mightly complicated, plus you couldn't only use other 3rd party accounts.

RPX Now claims to be super easy and so far, with grosser's rpx_now gem, it almost seems too easy -- except there are no tutorials that I can find on Google. There are examples in gem's github site but they don't explain much.

This is my attempt at writing one.

First, install the gem (instructions in the github site). If you want to put it in your environment.rb file, it should look like this (remove or replace the version number with an updated one):
config.gem "grosser-rpx_now", :lib => "rpx_now", :version => "0.3", :source => "http://gems.github.com"
Then create an RpxController and add code similar to this to your user model. Of course, you don't have to process the data yourself, but I wanted to (thus my rpx_controller is a bit longer, and I had to read the response in the User model) so that if the rpx profile is missing anything, it will render a something like my normal login page that basically has a form_for(@user ...) where they can fill up the missing data.

Check out actual responses (I just removed any personal data).

2 comments:

Unknown said...

Hi,

Thanks for the information.
I have a very newbie question.
Can you tell me if the url i've configured is correct??

RPXNow.embed_code('pratik.homedns.org:3008/mosaicit', url_for(:controller => :user_sessions, :action => :rpx_token))

Unknown said...

Am getting the following error:

The webpage at https://pratik.homedns.org/mosaicit.rpxnow.com/openid/embed?token_url=/user_sessions/rpx_token

might be temporarily down or it may have moved permanently to a new web address.