OmniAuth is a flexible authentication system utilizing Rack middleware.
Перейти к файлу
Michael Bleigh bbc6580da2 At last, Attribute Exchange for OpenID worked out to properly provide names from Google. 2010-10-19 12:46:42 -05:00
oa-basic Removing Gemfile.lock files because of local paths. - Closes #39 2010-10-12 09:28:33 -05:00
oa-core Small fixes to TripIt and Dopplr support. Closes #60. 2010-10-19 09:41:53 -05:00
oa-enterprise Merge branch 'master' of github.com:intridea/omniauth 2010-10-18 16:44:46 -05:00
oa-oauth Fixing TripIt spec. 2010-10-19 09:48:31 -05:00
oa-openid At last, Attribute Exchange for OpenID worked out to properly provide names from Google. 2010-10-19 12:46:42 -05:00
omniauth Removing Gemfile.lock files because of local paths. - Closes #39 2010-10-12 09:28:33 -05:00
.document Initial commit to rack-oauthable. 2010-03-25 19:37:03 -04:00
.gitignore Merge branch 'master' of github.com:intridea/omniauth 2010-10-18 16:44:46 -05:00
LICENSE Adds license. Closes #64 2010-10-19 11:06:21 -05:00
README.markdown Adds license. Closes #64 2010-10-19 11:06:21 -05:00
Rakefile Updating lots of documentation. 2010-10-14 16:21:08 -05:00
VERSION Bumping version to 0.1.5 2010-10-19 09:48:47 -05:00
development_dependencies.rb Updated to 0.0.4. 2010-08-16 10:21:46 -05:00
rspec.watchr Moved 37signals into a single OAuth2 class. 2010-06-23 20:15:43 -04:00

README.markdown

OmniAuth: Standardized Multi-Provider Authentication

OmniAuth is a new Rack-based authentication system for multi-provider external authentcation. OmniAuth is built from the ground up on the philosophy that authentication is not the same as identity, and is based on two observations:

  1. The traditional 'sign up using a login and password' model is becoming the exception, not the rule. Modern web applications offer external authentication via OpenID, Facebook, and/or OAuth.
  2. The interconnectable web is no longer a dream, it is a necessity. It is not unreasonable to expect that one application may need to be able to connect to one, three, or twelve other services. Modern authentication systems should allow a user's identity to be associated with many authentications.

Installation

To install OmniAuth, simply install the gem:

gem install omniauth

Providers

OmniAuth currently supports the following external providers:

  • via OAuth
    • Facebook
    • Twitter
    • 37signals ID
    • Foursquare
    • LinkedIn
    • GitHub
    • Identi.ca (credit: dcu)
    • Gowalla (credit: kvnsmth)
    • Dopplr (credit: flextrip)
    • TripIt (credit: flextrip)
  • OpenID
  • Google Apps (via OpenID)
  • CAS (Central Authentication Service) (credit: jamesarosen)
  • LDAP (credit: Ping Yu)

Usage

OmniAuth is a collection of Rack middleware. To use a single strategy, you simply need to add the middleware:

require 'oa-oauth'
use OmniAuth::Strategies::Twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'

Now to initiate authentication you merely need to redirect the user to /auth/twitter via a link or other means. Once the user has authenticated to Twitter, they will be redirected to /auth/twitter/callback. You should build an endpoint that handles this URL, at which point you will will have access to the authentication information through the omniauth.auth parameter of the Rack environment. For example, in Sinatra you would do something like this:

get '/auth/twitter/callback' do
  auth_hash = request.env['omniauth.auth']
end

The hash in question will look something like this:

{
  'uid' => '12356',
  'provider' => 'twitter',
  'user_info' => {
    'name' => 'User Name',
    'nickname' => 'username',
    # ...
  }
}

The user_info hash will automatically be populated with as much information about the user as OmniAuth was able to pull from the given API or authentication provider.

Resources

The best place to find more information is the OmniAuth Wiki. Some specific information you might be interested in:

License

OmniAuth is licensed under the MIT License.