Question

I went through quite a lot of Rails/Rails examples of Google OpenID authentication, but none of them worked properly. Most of them don't work because they are out of date. Even omniauth doesn't for some other reason.

Does anyone have a working example of Ruby Rack web application which works properly now?

Was it helpful?

Solution

I forked one a while back and popped it up on GitHub called rails3-mongoid-omniauth.

It lets you authenticate using a variety of methods. It provably runs on the Bamboo stack on Heroku with Rails 3.0.x. I haven't updated it, but it should give you some insights.

Some of the key files are:

  • omniauth.rb where the providers are declared. It also includes a monkeypatch to fix the LinkedIn provider, although I suspect that it has been fixed by now.
  • routes.rb where the route to this app is defined for each authentication provider. This is the callback URL which omniauth sends to the provider.
  • application_controller.rb where the current_user is defined based on the session key.
  • sessions_controller.rb where the session is created based on authorization from the authentication provider (e.g. Google)
  • _navigation.html.erb where the sign-in links take you to the authentication provider.

Now that I have done some more research, it looks like there is also a tutorial at http://railsapps.github.com/tutorial-rails-mongoid-omniauth.html.

OTHER TIPS

I would check this Rails Cast which should help get you up and running on On Open ID and omniauth in general on Rails/Rack based Ruby apps

http://railscasts.com/episodes/304-omniauth-identity

By the way if you are going to be doing allot of Rails development Railscast is a excellent source of information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top