OmniAuth is a Ruby authentication framework that provides a standardized interface to many different authentication providers such as Facebook, OpenID, and even traditional username and password.

Quick Links

Getting Started

To use OmniAuth in a project with a Gemfile, just add each of the strategies you want to use individually:

gem ‘omniauth-github’
gem ‘omniauth-openid’

Now you can use the OmniAuth::Builder Rack middleware to build up your list of OmniAuth strategies for use in your application:

use OmniAuth::Builder do
provider :github, ENV[‘GITHUB_KEY’], ENV[‘GITHUB_SECRET’]
provider :openid, :store =>‘/tmp’)

By default, OmniAuth will return auth information to the path /auth/:provider/callback inside the Rack environment. In Sinatra, for example, a callback might look something like this:

# Support both GET and POST for callbacks
%w(get post).each do |method|
send(method, “/auth/:provider/callback”) do env[‘omniauth.auth’] # => OmniAuth::AuthHash

For additional documentation, you should see the OmniAuth wiki.

Try OmniAuth!

Want an idea of the different providers OmniAuth gives you the ability to authenticate through? Try out any of the providers in the list below, each one is a live example of authenticating with OmniAuth!