Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	VERSION
	oa-oauth/lib/omniauth/oauth.rb
  • Loading branch information
sferik committed May 25, 2011
2 parents 5271a9d + 2e4a534 commit 2b31822
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 25 deletions.
56 changes: 33 additions & 23 deletions README.md
@@ -1,26 +1,36 @@
# 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

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

## Continuous Integration
Continuous Integration
----------------------
[![Build Status](http://travis-ci.org/intridea/omniauth.png)](http://travis-ci.org/intridea/omniauth)

## Providers

Providers
---------
OmniAuth currently supports the following external providers:

* via OAuth (OAuth 1.0, OAuth 2, and xAuth)
* 37signals ID (credit: [mbleigh](https://github.com/mbleigh))
* Bit.ly (credit: [philnash](https://github.com/philnash))
* Blogger (credit: [dsueiro-backing](https://github.com/dsueiro-backing))
* DailyMile (credit: [cdmwebs](https://github.com/cdmwebs))
* Doit.im (credit: [chouti](https://github.com/chouti))
* Dopplr (credit: [flextrip](https://github.com/flextrip))
Expand Down Expand Up @@ -69,19 +79,19 @@ OmniAuth currently supports the following external providers:
* OpenID (credit: [mbleigh](https://github.com/mbleigh))
* Yupoo (credit: [chouti](https://github.com/chouti))

## Compatibility

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)
* JRuby (note, the Evernote strategy is not available for JRuby)
* Rubinius
* REE

## Usage

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

require 'oa-oauth'
Expand All @@ -107,8 +117,8 @@ The hash in question will look something like this:

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

Resources
---------
The best place to find more information is the [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki). Some specific information you might be interested in:

* [CI Build Status](http://travis-ci.org/#!/intridea/omniauth)
Expand All @@ -117,11 +127,11 @@ The best place to find more information is the [OmniAuth Wiki](https://github.co
* [Report Issues](https://github.com/intridea/omniauth/issues)
* [Mailing List](http://groups.google.com/group/omniauth)

## OmniAuth Core

OmniAuth Core
-------------
* **Michael Bleigh** ([mbleigh](https://github.com/mbleigh))
* **Erik Michaels-Ober** ([sferik](https://github.com/sferik))

## License

License
-------
OmniAuth is licensed under the MIT License.
5 changes: 3 additions & 2 deletions oa-oauth/lib/omniauth/oauth.rb
Expand Up @@ -7,6 +7,7 @@ module Strategies
autoload :XAuth, 'omniauth/strategies/xauth'

autoload :Bitly, 'omniauth/strategies/bitly'
autoload :Blogger, 'omniauth/strategies/blogger'
autoload :Dailymile, 'omniauth/strategies/dailymile'
autoload :Doit, 'omniauth/strategies/doit'
autoload :Dopplr, 'omniauth/strategies/dopplr'
Expand All @@ -23,6 +24,7 @@ module Strategies
autoload :Instagram, 'omniauth/strategies/instagram'
autoload :Instapaper, 'omniauth/strategies/instapaper'
autoload :LinkedIn, 'omniauth/strategies/linked_in'
autoload :Mailru, 'omniauth/strategies/mailru'
autoload :Meetup, 'omniauth/strategies/meetup'
autoload :Miso, 'omniauth/strategies/miso'
autoload :Mixi, 'omniauth/strategies/mixi'
Expand All @@ -35,7 +37,7 @@ module Strategies
autoload :SmugMug, 'omniauth/strategies/smug_mug'
autoload :SoundCloud, 'omniauth/strategies/sound_cloud'
autoload :T163, 'omniauth/strategies/t163'
autoload :TB, 'omniauth/strategies/taobao'
autoload :TB, 'omniauth/strategies/taobao'
autoload :Teambox, 'omniauth/strategies/teambox'
autoload :ThirtySevenSignals, 'omniauth/strategies/thirty_seven_signals'
autoload :Tqq, 'omniauth/strategies/tqq'
Expand All @@ -51,6 +53,5 @@ module Strategies
autoload :Yahoo, 'omniauth/strategies/yahoo'
autoload :Yammer, 'omniauth/strategies/yammer'
autoload :YouTube, 'omniauth/strategies/you_tube'
autoload :Mailru, 'omniauth/strategies/mailru'
end
end
65 changes: 65 additions & 0 deletions oa-oauth/lib/omniauth/strategies/blogger.rb
@@ -0,0 +1,65 @@
# Based heavily on the Google strategy, monkeypatch and all

require 'omniauth/oauth'
require 'multi_json'

module OmniAuth
module Strategies
#
# Authenticate to YouTube via OAuth and retrieve basic user info.
#
# Usage:
#
# use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret'
#
class Blogger < OmniAuth::Strategies::OAuth
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
client_options = {
:site => 'https://www.google.com',
:request_token_path => '/accounts/OAuthGetRequestToken',
:access_token_path => '/accounts/OAuthGetAccessToken',
:authorize_path => '/accounts/OAuthAuthorizeToken'
}

super(app, :blogger, consumer_key, consumer_secret, client_options, options)
end

def auth_hash
ui = user_info
OmniAuth::Utils.deep_merge(super, {
'uid' => ui['uid'],
'user_info' => ui,
'extra' => {'user_hash' => user_hash}
})
end

#TODO: Remove contact list from hash returned to the application
def user_info
{
'uid' => user_hash['feed']['author'][0]['email']['$t'],
'nickname' => user_hash['feed']['author'][0]['name']['$t']
}
end

def user_hash
# Using Contact feed
@user_hash ||= MultiJson.decode(@access_token.get("https://www.google.com/m8/feeds/contacts/default/full/?alt=json").body)
end

def request_phase
request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://www.blogger.com/feeds/ http://www.google.com/m8/feeds/'})
session['oauth'] ||= {}
session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
r = Rack::Response.new

if request_token.callback_confirmed?
r.redirect(request_token.authorize_url)
else
r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
end

r.finish
end
end
end
end

0 comments on commit 2b31822

Please sign in to comment.