2011-04-07 21:24:31 -04:00
# OmniAuth: Standardized Multi-Provider Authentication
2010-04-04 23:30:40 -04:00
2010-10-01 11:31:02 -04:00
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:
2010-04-04 23:30:40 -04:00
2010-04-05 01:20:34 -04:00
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.
2010-10-01 11:31:02 -04:00
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.
2010-04-04 23:30:40 -04:00
2010-10-01 11:31:02 -04:00
## Installation
2010-04-04 23:30:40 -04:00
2010-10-01 11:31:02 -04:00
To install OmniAuth, simply install the gem:
2010-04-04 23:30:40 -04:00
2010-10-01 11:31:02 -04:00
gem install omniauth
2011-04-23 19:38:22 -04:00
2010-10-01 11:31:02 -04:00
## Providers
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
OmniAuth currently supports the following external providers:
2010-04-05 01:20:34 -04:00
2011-03-10 18:21:26 -05:00
* via OAuth (OAuth 1.0, OAuth 2, and xAuth)
2011-04-24 22:01:22 -04:00
* 37signals ID (credit: [mbleigh ](https://github.com/mbleigh ))
2011-02-04 10:12:26 -05:00
* Bit.ly (credit: [philnash ](https://github.com/philnash ))
2011-04-05 11:11:59 -04:00
* DailyMile (credit: [cdmwebs ](https://github.com/cdmwebs ))
* Doit.im (credit: [chouti ](https://github.com/chouti ))
2011-02-04 10:12:26 -05:00
* Dopplr (credit: [flextrip ](https://github.com/flextrip ))
2011-04-24 18:11:49 -04:00
* Douban (credit: [quake ](https://github.com/quake ))
2011-04-05 11:11:59 -04:00
* Evernote (credit: [szimek ](https://github.com/szimek ))
2011-04-24 22:01:22 -04:00
* Facebook (credit: [mbleigh ](https://github.com/mbleigh ))
* Foursquare (credit: [mbleigh ](https://github.com/mbleigh ))
* GitHub (credit: [mbleigh ](https://github.com/mbleigh ))
2011-02-04 10:12:26 -05:00
* GoodReads (credit: [cristoffer ](https://github.com/christoffer ))
2011-01-12 22:35:15 -05:00
* Gowalla (credit: [kvnsmth ](https://github.com/kvnsmth ))
2011-02-04 10:12:26 -05:00
* Hyves (credit: [mrdg ](https://github.com/mrdg ))
* Identi.ca (credit: [dcu ](https://github.com/dcu ))
2011-04-05 11:11:59 -04:00
* Instagram (credit: [kiyoshi ](https://github.com/kiyoshi ))
* Instapaper (credit: [micpringle ](https://github.com/micpringle ))
2011-04-24 22:01:22 -04:00
* LinkedIn (credit: [mbleigh ](https://github.com/mbleigh ))
2011-04-29 03:38:24 -04:00
* Mailru (credit: [lexer ](https://github.com/lexer ))
2011-01-12 22:35:15 -05:00
* Meetup (credit [coderoshi ](https://github.com/coderoshi ))
2011-04-05 11:11:59 -04:00
* Miso (credit: [rickenharp ](https://github.com/rickenharp ))
* Mixi (credit: [kiyoshi ](https://github.com/kiyoshi ))
2011-01-12 22:35:15 -05:00
* Netflix (credit: [caged ](https://github.com/caged ))
2011-04-24 18:11:49 -04:00
* Qzone (credit: [quake ](https://github.com/quake ))
2011-04-23 19:38:22 -04:00
* Rdio (via [brandonweiss ](http://github.com/brandonweiss ))
2011-04-24 18:11:49 -04:00
* Renren (credit: [quake ](https://github.com/quake ))
2011-04-05 11:16:27 -04:00
* Salesforce (via [CloudSpokes ](http://www.cloudspokes.com ))
2011-02-04 10:12:26 -05:00
* SmugMug (credit: [pchilton ](https://github.com/pchilton ))
* SoundCloud (credit: [leemartin ](https://github.com/leemartin ))
2011-04-24 18:11:49 -04:00
* T163 (credit: [quake ](https://github.com/quake ))
2011-04-06 20:48:26 -04:00
* TeamBox (credit [jrom ](https://github.com/jrom ))
2011-04-24 18:11:49 -04:00
* Tqq (credit: [quake ](https://github.com/quake ))
2011-03-11 07:09:52 -05:00
* TradeMe (credit: [pchilton ](https://github.com/pchilton ))
2011-02-04 10:12:26 -05:00
* TripIt (credit: [flextrip ](https://github.com/flextrip ))
2011-04-24 18:11:49 -04:00
* Tsina (credit: [quake ](https://github.com/quake ))
* Tsohu (credit: [quake ](https://github.com/quake ))
2011-04-06 20:48:26 -04:00
* Tumblr (credit: [jamiew ](https://github.com/jamiew ))
2011-04-24 22:01:22 -04:00
* Twitter (credit: [mbleigh ](https://github.com/mbleigh ))
2011-01-30 11:45:32 -05:00
* Vimeo (credit: [jamiew ](https://github.com/jamiew ))
2011-04-20 13:42:26 -04:00
* Vkontakte (credit: [german ](https://github.com/german ))
2011-04-24 22:01:22 -04:00
* Yammer (credit: [kltcalamay ](https://github.com/kltcalamay ))
2011-01-30 11:45:32 -05:00
* YouTube (credit: [jamiew ](https://github.com/jamiew ))
2011-01-12 22:35:15 -05:00
* CAS (Central Authentication Service) (credit: [jamesarosen ](https://github.com/jamesarosen ))
2011-03-11 10:31:13 -05:00
* Flickr (credit: [pchilton ](https://github.com/pchilton ))
2011-04-25 08:25:15 -04:00
* Google Apps (via OpenID) (credit: [mbleigh ](https://github.com/mbleigh ))
* LDAP (credit: [pyu10055 ](https://github.com/pyu10055 ))
* OpenID (credit: [mbleigh ](https://github.com/mbleigh ))
* Yupoo (credit: [chouti ](https://github.com/chouti ))
2010-04-05 01:20:34 -04:00
2011-04-07 20:34:38 -04:00
## Compatibility
OmniAuth is tested against the following Ruby versions:
* 1.8.7
* 1.9.1
* 1.9.2
* jRuby (note, the Evernote strategy is not available for jRuby)
* Rubinius
* REE
2010-10-01 11:31:02 -04:00
## Usage
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
OmniAuth is a collection of Rack middleware. To use a single strategy, you simply need to add the middleware:
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
require 'oa-oauth'
use OmniAuth::Strategies::Twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
2011-04-23 19:38:22 -04:00
2010-10-11 12:17:12 -04:00
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:
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
get '/auth/twitter/callback' do
2010-10-11 12:17:12 -04:00
auth_hash = request.env['omniauth.auth']
2010-10-01 11:31:02 -04:00
end
2011-04-23 19:38:22 -04:00
2010-10-01 11:31:02 -04:00
The hash in question will look something like this:
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
{
'uid' => '12356',
'provider' => 'twitter',
2010-04-05 01:20:34 -04:00
'user_info' => {
2010-10-01 11:31:02 -04:00
'name' => 'User Name',
'nickname' => 'username',
# ...
2010-04-05 01:20:34 -04:00
}
}
2011-04-23 19:38:22 -04:00
2010-10-01 11:31:02 -04:00
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.
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
## Resources
2010-04-05 01:20:34 -04:00
2010-10-01 11:31:02 -04:00
The best place to find more information is the [OmniAuth Wiki ](http://github.com/intridea/omniauth/wiki ). Some specific information you might be interested in:
2011-04-07 21:24:31 -04:00
* [CI Build Status ](http://travis-ci.org/#!/intridea/omniauth )
2010-10-01 11:31:02 -04:00
* [Roadmap ](http://github.com/intridea/omniauth/wiki/Roadmap )
* [Changelog ](http://github.com/intridea/omniauth/wiki/Changelog )
* [Report Issues ](http://github.com/intridea/omniauth/issues )
2010-10-19 12:06:21 -04:00
* [Mailing List ](http://groups.google.com/group/omniauth )
2011-04-24 22:01:22 -04:00
## OmniAuth Core
* **Michael Bleigh** ([mbleigh](https://github.com/mbleigh))
* **Erik Michaels-Ober** ([sferik](https://github.com/sferik))
2010-10-19 12:06:21 -04:00
## License
2010-12-29 11:45:48 -05:00
OmniAuth is licensed under the MIT License.