Omniauth - Easy Authentication for your Rails Projects

I just came across this wonderful little gem that makes authentication on your rails application a breeze. This is exactly the gem that I wished was around a year ago when I was developing Baboonza.com (now defunct) and my various mini project sites.

Usually when I start a new rails project, I would use Authlogic and tweaked it to allow openid authentication. If you’ve used authlogic before, you would know that the entire process of just installing the gem and getting all your user models and controllers setup is god awful tedious. It is because of this very reason that I started to develop a rails app template to help keep the redundant work to a minimal.

Before I go any further, I thought I clarify. I was in no way trying to beat down Authlogic. It is still a wonderful gem if you’re going to want to store and authenticate your users locally and I’d still recommend it over other authentication plugins.

But it looks like after today, I’ll no longer have to go that path.

Omniauth is a very cool Rack middleware that hooks your authentication system up to allow logins via multiple providers like Facebook, 37signals ID, Foursquare, Twitter etc. So you can actually give your users a choice as to which providers' login accounts they can use with your app.

With most of the world having at least an account with either Facebook or Google, theres no longer a need to store, register and authenticate user registration internally. Why reinvent the wheel?

I know I should probably paste some code snipplets here but honestly its just going to be a rehash of what various other people have already written, so instead, I’m going to just direct you to some really useful resources that helped me get this gem working in less than an hour.

ASCIICast - #241 Simple Omniauth Omniauth’s Github page A quick introduction of Omniauth by the creators of the gem