What is Omniauth?

The web application landscape has changed drastically in the past few years. Most users login in to dozens, sometimes hundreds of services each day; sites are no longer silos unto themselves and cannot reasonably expect users to create a unique login and password for each service. This is where OmniAuth comes in.

OmniAuth is a library that standardizes multi-provider authentication for web applications. It was created to be powerful, secure, and flexible. Any developer can create strategies for OmniAuth that can authenticate users via disparate systems. OmniAuth strategies have been created for everything from Facebook to LDAP.

Who’s Using OmniAuth?

Hundreds of people are leveraging the advantages of super simple, secure authentication with OmniAuth in their applications. From event registration sites to online wholesale distribution stores, to online trading platforms and beyond, developers are relying on OmniAuth to streamline user authentication in their systems.

  • GitHub
  • Hall
  • Intridea

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 => OpenID::Store::Filesystem.new('/tmp')
end

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
end
end

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!

Resources

Created By:

Michael Bleigh

Michael has been with Intridea since 2007 and works to build Intridea's portfolio of products. With many years of experience working as both a designer and a developer, Michael specializes in helping to bridge the gap between the back-end development and the front-end design of a project.

Michael is a prolific member of the Ruby on Rails community, having released popular open source libraries such as OmniAuth and spoken at conferences including RailsConf and RubyConf.