From 485b9e3867635a0961f09f5d858a6c6392997f28 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Tue, 9 Aug 2011 15:25:53 -0700 Subject: [PATCH 01/45] first revision of etsy authentication --- oa-core/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/oauth.rb | 1 + oa-oauth/lib/omniauth/strategies/etsy.rb | 103 +++++++++++++++++++++++ oa-oauth/lib/omniauth/version.rb | 2 +- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 oa-oauth/lib/omniauth/strategies/etsy.rb diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 91476f067..9cebe9d00 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 2 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 6 + PATCH = 7 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb index 65b3284f6..390f6ad29 100644 --- a/oa-oauth/lib/omniauth/oauth.rb +++ b/oa-oauth/lib/omniauth/oauth.rb @@ -11,6 +11,7 @@ module Strategies autoload :Doit, 'omniauth/strategies/doit' autoload :Dopplr, 'omniauth/strategies/dopplr' autoload :Douban, 'omniauth/strategies/douban' + autoload :Etsy, 'omniauth/strategies/etsy' autoload :Evernote, 'omniauth/strategies/evernote' autoload :Facebook, 'omniauth/strategies/facebook' autoload :Foursquare, 'omniauth/strategies/foursquare' diff --git a/oa-oauth/lib/omniauth/strategies/etsy.rb b/oa-oauth/lib/omniauth/strategies/etsy.rb new file mode 100644 index 000000000..bddd30ede --- /dev/null +++ b/oa-oauth/lib/omniauth/strategies/etsy.rb @@ -0,0 +1,103 @@ +require 'omniauth/oauth' +require 'multi_json' + +module OmniAuth + module Strategies + class Etsy < OmniAuth::Strategies::OAuth + + # Cribbed from the etsy gem. + SANDBOX_HOST = 'sandbox.openapi.etsy.com' + PRODUCTION_HOST = 'openapi.etsy.com' + + # Set the environment, accepts either :sandbox or :production. Defaults to :production + # and will raise an exception when set to an unrecognized environment. + # + def self.environment=(environment) + unless [:sandbox, :production].include?(environment) + raise(ArgumentError, "environment must be set to either :sandbox or :production") + end + @environment = environment + @host = (environment == :sandbox) ? SANDBOX_HOST : PRODUCTION_HOST + end + + # The currently configured environment. + def self.environment + @environment || :sandbox + end + + def self.host # :nodoc: + @host || PRODUCTION_HOST + end + + def self.callback_url + @callback_url || 'oob' + end + + def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) + client_options = { + :site => "http://#{Etsy.host}", + :request_token_path => request_token_path(options), + :access_token_path => access_token_path, + :http_method => :get, + :scheme => :query_string + } + + super(app, :etsy, consumer_key, consumer_secret, client_options, options, &block) + end + + def request_phase + request_token = consumer.get_request_token(:oauth_callback => callback_url) + session['oauth'] ||= {} + session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret} + r = Rack::Response.new + if request_token.params[:login_url] + # Already contains token, etc, of the form: + # https://www.etsy.com/oauth/signin?oauth_consumer_key=wg30ji4z8kdzsymfkw9vm333&oauth_token=650a9d4a8d589bb7e6aefed1628885&service=v2_prod + r.redirect(request_token.params[:login_url]) + end + r.finish + end + + def auth_hash + OmniAuth::Utils.deep_merge(super, { + 'uid' => user_hash['user_id'], + 'user_info' => user_info, + 'extra' => { 'user_hash' => user_hash } + }) + end + + def user_info + return {} unless user_hash + { + 'uid' => user_hash['user_id'], + 'nickname' => user_hash['login_name'], + 'email' => user_hash['primary_email'], + 'name' => user_hash['login_name'], + 'feedback_info' => user_hash['feedback_info'] + } + end + + def request_token_path(options) + # Default scope is to read a user's private profile information, including email. Scope is specified + # as a uri-encoded query kv pair, "scope=scope_1+scope_2+...+scope_n" + # For a full list of scope options, see: + # http://www.etsy.com/developers/documentation/getting_started/oauth + "/v2/oauth/request_token?#{to_params({:scope => options.fetch(:scope, 'profile_r+email_r')})}" + end + + def access_token_path + "/v2/oauth/access_token" + end + + def to_params(options) + options.collect{|key, value| "#{key}=#{value}"}.join('&') + end + + def user_hash + @user_hash ||= MultiJson.decode(@access_token.get('/v2/users/__SELF__').body)['results'][0] + rescue ::Errno::ETIMEDOUT + raise ::Timeout::Error + end + end + end +end diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 91476f067..9cebe9d00 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 2 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 6 + PATCH = 7 end unless defined?(::OmniAuth::Version::PRE) PRE = nil From 2ee973908f1bc40318467d99c09aa9ce1b9301b4 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Tue, 9 Aug 2011 15:34:34 -0700 Subject: [PATCH 02/45] remove unnecessary whitespace --- oa-oauth/lib/omniauth/strategies/etsy.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/etsy.rb b/oa-oauth/lib/omniauth/strategies/etsy.rb index bddd30ede..7cd50d52a 100644 --- a/oa-oauth/lib/omniauth/strategies/etsy.rb +++ b/oa-oauth/lib/omniauth/strategies/etsy.rb @@ -60,10 +60,10 @@ def request_phase def auth_hash OmniAuth::Utils.deep_merge(super, { - 'uid' => user_hash['user_id'], - 'user_info' => user_info, - 'extra' => { 'user_hash' => user_hash } - }) + 'uid' => user_hash['user_id'], + 'user_info' => user_info, + 'extra' => { 'user_hash' => user_hash } + }) end def user_info From b918f0702c70ca054c7f4956377546c537c8b375 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Tue, 9 Aug 2011 15:36:30 -0700 Subject: [PATCH 03/45] adding spec file for etsy --- oa-oauth/spec/omniauth/strategies/etsy_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 oa-oauth/spec/omniauth/strategies/etsy_spec.rb diff --git a/oa-oauth/spec/omniauth/strategies/etsy_spec.rb b/oa-oauth/spec/omniauth/strategies/etsy_spec.rb new file mode 100644 index 000000000..b0281cc83 --- /dev/null +++ b/oa-oauth/spec/omniauth/strategies/etsy_spec.rb @@ -0,0 +1,5 @@ +require File.expand_path('../../../spec_helper', __FILE__) + +describe OmniAuth::Strategies::Etsy do + it_should_behave_like "an oauth strategy" +end From c608937d9923252c6531e4ee6ac77128ab1659b4 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Tue, 9 Aug 2011 16:24:06 -0700 Subject: [PATCH 04/45] changing vesion to 0.2.6.1.copious --- oa-core/lib/omniauth/version.rb | 4 ++-- oa-oauth/lib/omniauth/version.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 9cebe9d00..44c8cbad5 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -7,10 +7,10 @@ module Version MINOR = 2 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 7 + PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = nil + PRE = "1.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 9cebe9d00..44c8cbad5 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -7,10 +7,10 @@ module Version MINOR = 2 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 7 + PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = nil + PRE = "1.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') From dd98c294a8a65d50e8a0b1ec50179be3a3fd5d26 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Wed, 10 Aug 2011 13:32:13 -0700 Subject: [PATCH 05/45] Backporting facebook oauth2 code from omniauth 0.3 (head) to fix https://copious.airbrakeapp.com/errors/10693789 --- oa-core/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/strategies/etsy.rb | 2 + oa-oauth/lib/omniauth/strategies/facebook.rb | 59 +++++++++++++------- oa-oauth/lib/omniauth/strategies/oauth2.rb | 12 ++-- oa-oauth/lib/omniauth/strategies/twitter.rb | 3 +- oa-oauth/lib/omniauth/version.rb | 2 +- oa-oauth/oa-oauth.gemspec | 2 +- 7 files changed, 52 insertions(+), 30 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 44c8cbad5..bc446ae7b 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = "1.copious" + PRE = "2.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/strategies/etsy.rb b/oa-oauth/lib/omniauth/strategies/etsy.rb index 7cd50d52a..e29fc6393 100644 --- a/oa-oauth/lib/omniauth/strategies/etsy.rb +++ b/oa-oauth/lib/omniauth/strategies/etsy.rb @@ -97,6 +97,8 @@ def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/v2/users/__SELF__').body)['results'][0] rescue ::Errno::ETIMEDOUT raise ::Timeout::Error + rescue ::OAuth::Error => e + raise e.response.inspect end end end diff --git a/oa-oauth/lib/omniauth/strategies/facebook.rb b/oa-oauth/lib/omniauth/strategies/facebook.rb index ea87e33ac..c984b8b4a 100644 --- a/oa-oauth/lib/omniauth/strategies/facebook.rb +++ b/oa-oauth/lib/omniauth/strategies/facebook.rb @@ -8,21 +8,46 @@ module Strategies # # @example Basic Usage # use OmniAuth::Strategies::Facebook, 'client_id', 'client_secret' - class Facebook < OAuth2 + class Facebook < OmniAuth::Strategies::OAuth2 # @param [Rack Application] app standard middleware application parameter # @param [String] client_id the application id as [registered on Facebook](http://www.facebook.com/developers/) # @param [String] client_secret the application secret as registered on Facebook # @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages` - def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) - super(app, :facebook, client_id, client_secret, {:site => 'https://graph.facebook.com/'}, options, &block) + def initialize(app, client_id=nil, client_secret=nil, options = {}, &block) + client_options = { + :site => 'https://graph.facebook.com/', + :token_url => '/oauth/access_token' + } + + options = { + :parse => :query + }.merge(options) + + super(app, :facebook, client_id, client_secret, client_options, options, &block) + end + + def auth_hash + OmniAuth::Utils.deep_merge( + super, { + 'uid' => user_data['id'], + 'user_info' => user_info, + 'extra' => { + 'user_hash' => user_data, + }, + } + ) end def user_data - @data ||= MultiJson.decode(@access_token.get('/me', {}, { "Accept-Language" => "en-us,en;"})) + @access_token.options[:mode] = :query + @access_token.options[:param_name] = 'access_token' + @data ||= @access_token.get('/me').parsed + rescue ::OAuth2::Error => e + raise e.response.inspect end def request_phase - options[:scope] ||= "email,offline_access" + options[:scope] ||= 'email,offline_access' super end @@ -30,7 +55,7 @@ def build_access_token if facebook_session.nil? || facebook_session.empty? super else - @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token']) + @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'], {:mode => :query, :param_name => 'access_token'}) end end @@ -45,26 +70,18 @@ def facebook_session def user_info { - 'nickname' => user_data["username"], - 'email' => (user_data["email"] if user_data["email"]), - 'first_name' => user_data["first_name"], - 'last_name' => user_data["last_name"], + 'nickname' => user_data['username'], + 'email' => (user_data['email'] if user_data['email']), + 'first_name' => user_data['first_name'], + 'last_name' => user_data['last_name'], 'name' => "#{user_data['first_name']} #{user_data['last_name']}", 'image' => "http://graph.facebook.com/#{user_data['id']}/picture?type=square", 'urls' => { - 'Facebook' => user_data["link"], - 'Website' => user_data["website"], - } + 'Facebook' => user_data['link'], + 'Website' => user_data['website'], + }, } end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => {'user_hash' => user_data} - }) - end end end end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2.rb b/oa-oauth/lib/omniauth/strategies/oauth2.rb index 5a3d1115b..ce655d567 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2.rb @@ -37,7 +37,7 @@ def initialize(error, error_reason=nil, error_uri=nil) # @param [String] client_id the client/application ID of this provider # @param [String] client_secret the client/application secret of this provider # @param [Hash] options that will be passed through to the OAuth2::Client (see [oauth2 docs](http://rubydoc.info/gems/oauth2)) - def initialize(app, name, client_id = nil, client_secret = nil, client_options = {}, options = {}, &block) + def initialize(app, name, client_id=nil, client_secret=nil, client_options={}, options={}, &block) self.client_id = client_id self.client_secret = client_secret self.client_options = client_options @@ -55,7 +55,7 @@ def callback_url protected def request_phase - redirect client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options)) + redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options)) end def callback_phase @@ -64,10 +64,10 @@ def callback_phase end @access_token = build_access_token - @access_token = client.web_server.refresh_access_token(@access_token.refresh_token) if @access_token.expired? + @access_token = client.auth_code.refresh_token(@access_token.refresh_token) if @access_token.expired? super - rescue ::OAuth2::HTTPError, ::OAuth2::AccessDenied, CallbackError => e + rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) @@ -77,7 +77,9 @@ def callback_phase def build_access_token verifier = request.params['code'] - client.web_server.get_access_token(verifier, {:redirect_uri => callback_url}.merge(options)) + client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options)) + rescue ::OAuth2::Error => e + raise e.response.inspect end def auth_hash diff --git a/oa-oauth/lib/omniauth/strategies/twitter.rb b/oa-oauth/lib/omniauth/strategies/twitter.rb index d08166de5..d58da8c8a 100644 --- a/oa-oauth/lib/omniauth/strategies/twitter.rb +++ b/oa-oauth/lib/omniauth/strategies/twitter.rb @@ -35,7 +35,6 @@ def auth_hash def user_info user_hash = self.user_hash - { 'nickname' => user_hash['screen_name'], 'name' => user_hash['name'] || user_hash['screen_name'], @@ -51,6 +50,8 @@ def user_info def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body) + rescue ::OAuth::Error => e + raise e.response.inspect end end end diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 44c8cbad5..bc446ae7b 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = "1.copious" + PRE = "2.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 0f7e56570..13065fa10 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'multi_xml', '~> 0.2.2' gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING gem.add_runtime_dependency 'oauth', '~> 0.4.0' - gem.add_runtime_dependency 'oauth2', '~> 0.4.1' + gem.add_runtime_dependency 'oauth2', '~> 0.5.0' gem.add_development_dependency 'evernote', '~> 0.9' gem.add_development_dependency 'maruku', '~> 0.6' gem.add_development_dependency 'rack-test', '~> 0.5' From e1f54458c01fd625273eb89a38368069edf7707b Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Wed, 24 Aug 2011 13:35:57 -0700 Subject: [PATCH 06/45] set etsy environment to correctly set host; use correct host; bump versions --- oa-core/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/strategies/etsy.rb | 7 ++++--- oa-oauth/lib/omniauth/version.rb | 2 +- oa-oauth/oa-oauth.gemspec | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index bc446ae7b..9f200ad74 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = "2.copious" + PRE = "3.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/strategies/etsy.rb b/oa-oauth/lib/omniauth/strategies/etsy.rb index e29fc6393..cf29c193d 100644 --- a/oa-oauth/lib/omniauth/strategies/etsy.rb +++ b/oa-oauth/lib/omniauth/strategies/etsy.rb @@ -11,7 +11,6 @@ class Etsy < OmniAuth::Strategies::OAuth # Set the environment, accepts either :sandbox or :production. Defaults to :production # and will raise an exception when set to an unrecognized environment. - # def self.environment=(environment) unless [:sandbox, :production].include?(environment) raise(ArgumentError, "environment must be set to either :sandbox or :production") @@ -22,7 +21,7 @@ def self.environment=(environment) # The currently configured environment. def self.environment - @environment || :sandbox + @environment || :production end def self.host # :nodoc: @@ -34,8 +33,10 @@ def self.callback_url end def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) + # Set environment first; this can update our host + OmniAuth::Strategies::Etsy.environment=options[:environment] if options[:environment] client_options = { - :site => "http://#{Etsy.host}", + :site => "http://#{OmniAuth::Strategies::Etsy.host}", :request_token_path => request_token_path(options), :access_token_path => access_token_path, :http_method => :get, diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index bc446ae7b..9f200ad74 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 6 end unless defined?(::OmniAuth::Version::PRE) - PRE = "2.copious" + PRE = "3.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 13065fa10..728ee0167 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'faraday', '~> 0.6.1' gem.add_runtime_dependency 'multi_json', '~> 1.0.0' gem.add_runtime_dependency 'multi_xml', '~> 0.2.2' - gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING + gem.add_runtime_dependency 'oa-core', ">= #{OmniAuth::Version::STRING}" gem.add_runtime_dependency 'oauth', '~> 0.4.0' gem.add_runtime_dependency 'oauth2', '~> 0.5.0' gem.add_development_dependency 'evernote', '~> 0.9' From 0aa9452a09607b245807ba92d5b40ec7fefb61e0 Mon Sep 17 00:00:00 2001 From: Bruno Mattarollo Date: Sat, 10 Sep 2011 18:21:40 +1000 Subject: [PATCH 07/45] Replacing Yammer OAuth with the new OAuth2 --- oa-oauth/lib/omniauth/oauth.rb | 2 +- .../lib/omniauth/strategies/oauth/yammer.rb | 48 -------------- .../lib/omniauth/strategies/oauth2/yammer.rb | 63 +++++++++++++++++++ .../{oauth => oauth2}/yammer_spec.rb | 2 +- 4 files changed, 65 insertions(+), 50 deletions(-) delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/yammer.rb create mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb rename oa-oauth/spec/omniauth/strategies/{oauth => oauth2}/yammer_spec.rb (60%) diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb index 10bdad773..f0ea01f49 100644 --- a/oa-oauth/lib/omniauth/oauth.rb +++ b/oa-oauth/lib/omniauth/oauth.rb @@ -36,7 +36,6 @@ module Strategies autoload :TypePad, 'omniauth/strategies/oauth/type_pad' autoload :Vimeo, 'omniauth/strategies/oauth/vimeo' autoload :Yahoo, 'omniauth/strategies/oauth/yahoo' - autoload :Yammer, 'omniauth/strategies/oauth/yammer' autoload :YouTube, 'omniauth/strategies/oauth/you_tube' autoload :OAuth2, 'omniauth/strategies/oauth2' @@ -65,6 +64,7 @@ module Strategies autoload :Viadeo, 'omniauth/strategies/oauth2/viadeo' autoload :Vkontakte, 'omniauth/strategies/oauth2/vkontakte' autoload :WePay, 'omniauth/strategies/oauth2/we_pay' + autoload :Yammer, 'omniauth/strategies/oauth2/yammer' autoload :XAuth, 'omniauth/strategies/xauth' diff --git a/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb b/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb deleted file mode 100644 index 9464f39d1..000000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Yammer < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'https://www.yammer.com', - } - super(app, :yammer, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'nickname' => user_hash['name'], - 'name' => user_hash['full-name'], - 'location' => user_hash['location'], - 'image' => user_hash['mugshot-url'], - 'description' => user_hash['job-title'], - 'urls' => { - 'Yammer' => user_hash['web-url'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb new file mode 100644 index 000000000..4d45b160b --- /dev/null +++ b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb @@ -0,0 +1,63 @@ +require 'omniauth/oauth' +require 'multi_json' + +module OmniAuth + module Strategies + # OAuth 2.0 based authentication with GitHub. In order to + # sign up for an application, you need to [register an application](http://github.com/account/applications/new) + # and provide the proper credentials to this middleware. + class Yammer < OmniAuth::Strategies::OAuth2 + def initialize(app, client_id=nil, client_secret=nil, options={}, &block) + client_options = { + :token_url => '/oauth2/access_token.json', + :authorize_url => '/dialog/oauth', + :site => 'https://www.yammer.com' + } + super(app, :yammer, client_id, client_secret, client_options, options, &block) + end + + def auth_hash + OmniAuth::Utils.deep_merge( + super, { + 'uid' => user_hash['id'], + 'user_info' => user_info, + 'extra' => { + 'user_hash' => user_hash, + }, + }, + ) + end + + def user_info + user_hash = self.user_hash + { + 'nickname' => user_hash['name'], + 'name' => user_hash['full_name'], + 'location' => user_hash['location'], + 'image' => user_hash['mugshot_url'], + 'description' => user_hash['job_title'], + 'email' => user_hash['contact']['email_addresses'][0]['address'], + 'urls' => { + 'Yammer' => user_hash['web_url'], + }, + } + end + + def build_access_token + # Dance to get the real token out of the object returned by Yammer + verifier = request.params['code'] + temp_access_token = client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options)) + token = eval(temp_access_token.token)['token'] + @access_token = ::OAuth2::AccessToken.new(client, token, temp_access_token.params) + rescue ::OAuth2::Error => e + raise e.response.inspect + end + + def user_hash + @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body) + end + + + end + end +end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/yammer_spec.rb similarity index 60% rename from oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb rename to oa-oauth/spec/omniauth/strategies/oauth2/yammer_spec.rb index b63ed2238..9e6807d8f 100644 --- a/oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb +++ b/oa-oauth/spec/omniauth/strategies/oauth2/yammer_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' describe OmniAuth::Strategies::Yammer do - it_should_behave_like 'an oauth strategy' + it_should_behave_like 'an oauth2 strategy' end From 2bfb88972663f146aae08e947787bc16d9fbcb9d Mon Sep 17 00:00:00 2001 From: Sooraj Balakrishnan Date: Sun, 11 Sep 2011 21:37:56 +0530 Subject: [PATCH 08/45] Fixed the missing space for google email scope --- oa-oauth/lib/omniauth/strategies/google_oauth2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb b/oa-oauth/lib/omniauth/strategies/google_oauth2.rb index 733031561..eb641f55c 100644 --- a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb +++ b/oa-oauth/lib/omniauth/strategies/google_oauth2.rb @@ -22,7 +22,7 @@ def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) def request_phase google_email_scope = "www.googleapis.com/auth/userinfo.email" options[:scope] ||= "https://#{google_email_scope}" - options[:scope] << "https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}] + options[:scope] << " https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}] redirect client.auth_code.authorize_url( {:redirect_uri => callback_url, :response_type => "code"}.merge(options)) end From 67bcf5ec521069226385e98e24342e88c293fb6e Mon Sep 17 00:00:00 2001 From: Umair Siddique Date: Mon, 12 Sep 2011 08:46:29 +0500 Subject: [PATCH 09/45] Added support for Facebook signed_request. --- .../omniauth/strategies/oauth2/facebook.rb | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb b/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb index c984b8b4a..6bbeb1073 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb @@ -52,11 +52,16 @@ def request_phase end def build_access_token - if facebook_session.nil? || facebook_session.empty? - super - else + if !signed_request.nil? && !signed_request.empty? + verifier = signed_request['code'] + client.auth_code.get_token(verifier, {:redirect_uri => ''}.merge(options)) + elsif !facebook_session.nil? && !facebook_session.empty? @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'], {:mode => :query, :param_name => 'access_token'}) + else + super end + rescue ::OAuth2::Error => e + raise e.response.inspect end def facebook_session @@ -68,6 +73,15 @@ def facebook_session end end + def signed_request + signed_request_cookie = request.cookies["fbsr_#{client.id}"] + if signed_request_cookie + signed_request = parse_signed_request(signed_request_cookie) + else + nil + end + end + def user_info { 'nickname' => user_data['username'], @@ -82,6 +96,35 @@ def user_info }, } end + + protected + # Borrowed from koala gem. + # + # Originally provided directly by Facebook, however this has changed + # as their concept of crypto changed. For historic purposes, this is their proposal: + # https://developers.facebook.com/docs/authentication/canvas/encryption_proposal/ + # Currently see https://github.com/facebook/php-sdk/blob/master/src/facebook.php#L758 + # for a more accurate reference implementation strategy. + def parse_signed_request(input) + encoded_sig, encoded_envelope = input.split('.', 2) + signature = base64_url_decode(encoded_sig).unpack("H*").first + envelope = MultiJson.decode(base64_url_decode(encoded_envelope)) + + raise "SignedRequest: Unsupported algorithm #{envelope['algorithm']}" if envelope['algorithm'] != 'HMAC-SHA256' + + # now see if the signature is valid (digest, key, data) + hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, client.secret, encoded_envelope.tr("-_", "+/")) + raise 'SignedRequest: Invalid signature' if (signature != hmac) + + return envelope + end + + # base 64 + # directly from https://github.com/facebook/crypto-request-examples/raw/master/sample.rb + def base64_url_decode(str) + str += '=' * (4 - str.length.modulo(4)) + Base64.decode64(str.tr('-_', '+/')) + end end end end From 4e75459b6f6250cd6855e1c5a4e129a2da17589b Mon Sep 17 00:00:00 2001 From: "Michael E. Gruen" Date: Thu, 15 Sep 2011 01:16:04 -0300 Subject: [PATCH 10/45] Fixed Goodreads strategy to work. (MultiXml returns a hash.) --- .../omniauth/strategies/oauth/goodreads.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb index 36665fe86..788011f0e 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb @@ -13,7 +13,7 @@ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) end def auth_hash - hash = user_info(@access_token) + hash = user_info OmniAuth::Utils.deep_merge( super, { @@ -25,18 +25,18 @@ def auth_hash def user_info(access_token) authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body) - id = authenticated_user.xpath('GoodreadsResponse/user').attribute('id').value.to_i - response_doc = MultiXml.parse(open("http://www.goodreads.com/user/show/#{id}.xml?key=#{@consumer_key}").read) - user = response_doc.xpath('GoodreadsResponse/user') + id = authenticated_user['GoodreadsResponse']['user']['id'].to_i + response_doc = MultiXml.parse(@access_token.get("/user/show/#{id}.xml?key=#{@consumer_key}").body) + user = response_doc['GoodreadsResponse']['user'] hash = { 'id' => id, - 'name' => user.xpath('name').text, - 'user_name' => user.xpath('user_name').text, - 'image_url' => user.xpath('image_url').text, - 'about' => user.xpath('about').text, - 'location' => user.xpath('location').text, - 'website' => user.xpath('website').text, + 'name' => user['name'], + 'user_name' => user['user_name'], + 'image_url' => user['image_url'], + 'about' => user['about'], + 'location' => user['location'], + 'website' => user['website'], } end end From 1512c2c6bf5efc9509ecc7fa757375659df305a2 Mon Sep 17 00:00:00 2001 From: "Michael E. Gruen" Date: Thu, 15 Sep 2011 01:42:04 -0300 Subject: [PATCH 11/45] Fixed typo on method definition. --- oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb index 788011f0e..651faedaa 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb @@ -23,7 +23,7 @@ def auth_hash ) end - def user_info(access_token) + def user_info authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body) id = authenticated_user['GoodreadsResponse']['user']['id'].to_i response_doc = MultiXml.parse(@access_token.get("/user/show/#{id}.xml?key=#{@consumer_key}").body) From 510c42069c06cc3e253505711ab312fb343d503b Mon Sep 17 00:00:00 2001 From: "Michael E. Gruen" Date: Thu, 15 Sep 2011 01:04:13 -0400 Subject: [PATCH 12/45] fixed method header --- oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb index 651faedaa..db689d97a 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb @@ -13,7 +13,7 @@ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) end def auth_hash - hash = user_info + hash = user_info(@access_token) OmniAuth::Utils.deep_merge( super, { @@ -23,10 +23,10 @@ def auth_hash ) end - def user_info - authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body) + def user_info(access_token) + authenticated_user = MultiXml.parse(access_token.get('/api/auth_user').body) id = authenticated_user['GoodreadsResponse']['user']['id'].to_i - response_doc = MultiXml.parse(@access_token.get("/user/show/#{id}.xml?key=#{@consumer_key}").body) + response_doc = MultiXml.parse(access_token.get("/user/show/#{id}.xml?key=#{@consumer_key}").body) user = response_doc['GoodreadsResponse']['user'] hash = { From 9137efddcd59974463d48dbb97ca8521bd2e7687 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 15 Sep 2011 11:33:35 -0700 Subject: [PATCH 13/45] Update multi_xml dependency to version 0.4.0 --- oa-oauth/oa-oauth.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 89c014932..555e02c1c 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -4,7 +4,7 @@ require File.expand_path('../lib/omniauth/version', __FILE__) Gem::Specification.new do |gem| gem.add_dependency 'faraday', '~> 0.7.3' gem.add_dependency 'multi_json', '~> 1.0.0' - gem.add_dependency 'multi_xml', '~> 0.3.0' + gem.add_dependency 'multi_xml', '~> 0.4.0' gem.add_dependency 'oa-core', OmniAuth::Version::STRING gem.add_dependency 'oauth', '~> 0.4.0' gem.add_dependency 'oauth2', '~> 0.5.0' From e22e77d32dc27942df2b0a639e3f8caa2ebfaf66 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 15 Sep 2011 12:03:00 -0700 Subject: [PATCH 14/45] Fix syntax error on Ruby 1.8 --- oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb index 4d45b160b..2c6e00710 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb @@ -24,7 +24,7 @@ def auth_hash 'extra' => { 'user_hash' => user_hash, }, - }, + } ) end @@ -56,8 +56,8 @@ def build_access_token def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body) end - - + + end end end From 2fb469bdd7e3829d2b0e54470d861e8be8a0bac3 Mon Sep 17 00:00:00 2001 From: Daniela Wellisz & Kevin Fitzpatrick Date: Mon, 19 Sep 2011 11:58:28 -0700 Subject: [PATCH 15/45] Make sure query params are copied over to omniauth.params in test mode. --- oa-core/lib/omniauth/strategy.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oa-core/lib/omniauth/strategy.rb b/oa-core/lib/omniauth/strategy.rb index 28d1ef8f1..d7cbd8335 100644 --- a/oa-core/lib/omniauth/strategy.rb +++ b/oa-core/lib/omniauth/strategy.rb @@ -107,6 +107,7 @@ def mock_callback_call @env['omniauth.auth'] = mocked_auth @env['omniauth.origin'] = session.delete('omniauth.origin') @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' + copy_query_params call_app! end end @@ -124,10 +125,14 @@ def request_phase raise NotImplementedError end - def callback_phase - @env['omniauth.auth'] = auth_hash + def copy_query_params @env['omniauth.params'] = session['query_params'] || {} session['query_params'] = nil if session['query_params'] + end + + def callback_phase + @env['omniauth.auth'] = auth_hash + copy_query_params call_app! end From 632f941953a2bf90681bd25058276309db277de8 Mon Sep 17 00:00:00 2001 From: Ryan Wilcox Date: Tue, 20 Sep 2011 11:03:09 -0400 Subject: [PATCH 16/45] allow SAML strategy to have a custom name --- oa-enterprise/lib/omniauth/strategies/saml.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/oa-enterprise/lib/omniauth/strategies/saml.rb b/oa-enterprise/lib/omniauth/strategies/saml.rb index 4238b11bc..a403f8e3c 100644 --- a/oa-enterprise/lib/omniauth/strategies/saml.rb +++ b/oa-enterprise/lib/omniauth/strategies/saml.rb @@ -8,11 +8,11 @@ class SAML autoload :AuthResponse, 'omniauth/strategies/saml/auth_response' autoload :ValidationError, 'omniauth/strategies/saml/validation_error' autoload :XMLSecurity, 'omniauth/strategies/saml/xml_security' - + @@settings = {} - + def initialize(app, options={}) - super(app, :saml) + super( app, (options[:name] || :saml) ) @@settings = { :assertion_consumer_service_url => options[:assertion_consumer_service_url], :issuer => options[:issuer], @@ -21,12 +21,12 @@ def initialize(app, options={}) :name_identifier_format => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" } end - + def request_phase request = OmniAuth::Strategies::SAML::AuthRequest.new redirect(request.create(@@settings)) end - + def callback_phase begin response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse']) @@ -36,15 +36,15 @@ def callback_phase super rescue ArgumentError => e fail!(:invalid_ticket, 'Invalid SAML Response') - end + end end - + def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => @name_id }) - end - + end + end end end From 58d5e143e740d07ce3f4b6390fe4cc3268644082 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Thu, 22 Sep 2011 11:44:13 -0500 Subject: [PATCH 17/45] Switch twitter back to /authenticate, Closes #466, Closes #478 --- oa-oauth/lib/omniauth/strategies/oauth/twitter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb b/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb index f9697bac9..7c2e05334 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb @@ -17,7 +17,7 @@ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) :site => 'https://api.twitter.com', } options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true - client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false + client_options[:authorize_path] = '/oauth/authenticate' unless options[:sign_in] == false super(app, options[:name] || :twitter, consumer_key, consumer_secret, client_options, options, &block) end From cc3391b5cc8b0b06756f2bdda7419e6c192e10b5 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Thu, 22 Sep 2011 11:46:26 -0500 Subject: [PATCH 18/45] Fix Twitter spec. How did that default get flipped anyway? --- oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb index cd2852381..d56c943d9 100644 --- a/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb +++ b/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb @@ -13,9 +13,9 @@ def app }.to_app end - it 'should use the authorize path by default' do + it 'should use the authenticate path by default' do s = strategy_class.new(app, 'abc', 'def') - s.consumer.options[:authorize_path].should == '/oauth/authorize' + s.consumer.options[:authorize_path].should == '/oauth/authenticate' end it 'should set options[:authorize_params] to { :force_login => "true" } if :force_login is true' do From bf0222628fd5d1894ea525f5ad86c685dcc153f3 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Thu, 22 Sep 2011 11:48:17 -0500 Subject: [PATCH 19/45] Bump version to 0.3.0 --- lib/omniauth/version.rb | 2 +- oa-basic/lib/omniauth/version.rb | 2 +- oa-core/lib/omniauth/version.rb | 2 +- oa-enterprise/lib/omniauth/version.rb | 2 +- oa-more/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/version.rb | 2 +- oa-openid/lib/omniauth/version.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/omniauth/version.rb b/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/lib/omniauth/version.rb +++ b/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-basic/lib/omniauth/version.rb b/oa-basic/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-basic/lib/omniauth/version.rb +++ b/oa-basic/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-enterprise/lib/omniauth/version.rb +++ b/oa-enterprise/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-more/lib/omniauth/version.rb b/oa-more/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-more/lib/omniauth/version.rb +++ b/oa-more/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-openid/lib/omniauth/version.rb b/oa-openid/lib/omniauth/version.rb index d811e439b..64dd11302 100644 --- a/oa-openid/lib/omniauth/version.rb +++ b/oa-openid/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 0 end unless defined?(::OmniAuth::Version::PRE) - PRE = "rc1" + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') From 80788e2a1502465286170a412ca3496484bed620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Scho=CC=88n?= Date: Tue, 27 Sep 2011 15:53:49 +0200 Subject: [PATCH 20/45] add XING strategy --- .../lib/omniauth/strategies/oauth/xing.rb | 47 +++++++++++++++++++ .../omniauth/strategies/oauth/xing_spec.rb | 5 ++ 2 files changed, 52 insertions(+) create mode 100644 oa-oauth/lib/omniauth/strategies/oauth/xing.rb create mode 100644 oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb diff --git a/oa-oauth/lib/omniauth/strategies/oauth/xing.rb b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb new file mode 100644 index 000000000..9693bf95d --- /dev/null +++ b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb @@ -0,0 +1,47 @@ +require 'json' +require 'omniauth/oauth' + +module OmniAuth + module Strategies + class Xing < OmniAuth::Strategies::OAuth + + def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) + client_options = { + :access_token_path => '/v1/access_token', + :authorize_path => '/v1/authorize', + :request_token_path => '/v1/request_token/', + :site => 'https://api.xing.com' + } + super(app, :xing, consumer_key, consumer_secret, client_options, options, &block) + end + + def callback_phase + session['oauth'][name.to_s]['callback_confirmed'] = true + super + end + + def auth_hash + hash = user_hash(@access_token) + + OmniAuth::Utils.deep_merge(super, + { + 'uid' => @access_token.params[:user_id], + 'user_info' => hash, + } + ) + end + + def user_hash(access_token) + person = JSON.parse( access_token.get('/v1/users/me').body )["users"].first + + hash = { + 'id' => person['id'], + 'first_name' => person['first_name'], + 'last_name' => person['last_name'], + 'image' => person["photo_urls"]["large"], + } + end + + end + end +end \ No newline at end of file diff --git a/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb new file mode 100644 index 000000000..71a80a919 --- /dev/null +++ b/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe OmniAuth::Strategies::XING do + it_should_behave_like "an oauth strategy" +end From 42d70560cc7a31bea992824dd4310987bf9fb7f5 Mon Sep 17 00:00:00 2001 From: Ryan Wilcox Date: Fri, 7 Oct 2011 14:41:45 -0400 Subject: [PATCH 21/45] add attributes (from the AttributeStatement parent) to the ominauth extras hash --- oa-enterprise/lib/omniauth/strategies/saml.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oa-enterprise/lib/omniauth/strategies/saml.rb b/oa-enterprise/lib/omniauth/strategies/saml.rb index 4238b11bc..66e7626d6 100644 --- a/oa-enterprise/lib/omniauth/strategies/saml.rb +++ b/oa-enterprise/lib/omniauth/strategies/saml.rb @@ -32,6 +32,7 @@ def callback_phase response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse']) response.settings = @@settings @name_id = response.name_id + @extra_attributes = response.attributes return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty? super rescue ArgumentError => e @@ -41,7 +42,8 @@ def callback_phase def auth_hash OmniAuth::Utils.deep_merge(super, { - 'uid' => @name_id + 'uid' => @name_id, + 'extra' => @extra_attributes }) end From 7fb89f471a69b7784bf8adb7a7c3ec56323c068e Mon Sep 17 00:00:00 2001 From: Ryan Wilcox Date: Fri, 7 Oct 2011 14:41:45 -0400 Subject: [PATCH 22/45] add attributes (from the AttributeStatement parent) to the ominauth extras hash --- oa-enterprise/lib/omniauth/strategies/saml.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oa-enterprise/lib/omniauth/strategies/saml.rb b/oa-enterprise/lib/omniauth/strategies/saml.rb index a403f8e3c..f5e49d587 100644 --- a/oa-enterprise/lib/omniauth/strategies/saml.rb +++ b/oa-enterprise/lib/omniauth/strategies/saml.rb @@ -32,6 +32,7 @@ def callback_phase response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse']) response.settings = @@settings @name_id = response.name_id + @extra_attributes = response.attributes return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty? super rescue ArgumentError => e @@ -41,7 +42,8 @@ def callback_phase def auth_hash OmniAuth::Utils.deep_merge(super, { - 'uid' => @name_id + 'uid' => @name_id, + 'extra' => @extra_attributes }) end From 72ca83341d88ec3843e9f7ca2a6d824df5790ec7 Mon Sep 17 00:00:00 2001 From: Christopher Warren Date: Tue, 11 Oct 2011 11:34:01 -0700 Subject: [PATCH 23/45] Added MySpace strategy --- oa-oauth/lib/omniauth/oauth.rb | 1 + .../lib/omniauth/strategies/oauth/my_space.rb | 71 +++++++++++++++++++ .../strategies/oauth/my_space_spec.rb | 5 ++ 3 files changed, 77 insertions(+) create mode 100644 oa-oauth/lib/omniauth/strategies/oauth/my_space.rb create mode 100644 oa-oauth/spec/omniauth/strategies/oauth/my_space_spec.rb diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb index f0ea01f49..2d2c1ce88 100644 --- a/oa-oauth/lib/omniauth/oauth.rb +++ b/oa-oauth/lib/omniauth/oauth.rb @@ -19,6 +19,7 @@ module Strategies autoload :LinkedIn, 'omniauth/strategies/oauth/linked_in' autoload :Meetup, 'omniauth/strategies/oauth/meetup' autoload :Miso, 'omniauth/strategies/oauth/miso' + autoload :MySpace, 'omniauth/strategies/oauth/my_space' autoload :Netflix, 'omniauth/strategies/oauth/netflix' autoload :Orkut, 'omniauth/strategies/oauth/orkut' autoload :Qzone, 'omniauth/strategies/oauth/qzone' diff --git a/oa-oauth/lib/omniauth/strategies/oauth/my_space.rb b/oa-oauth/lib/omniauth/strategies/oauth/my_space.rb new file mode 100644 index 000000000..f4d725747 --- /dev/null +++ b/oa-oauth/lib/omniauth/strategies/oauth/my_space.rb @@ -0,0 +1,71 @@ +require 'json' +require 'omniauth/oauth' + +module OmniAuth + module Strategies + class MySpace < OmniAuth::Strategies::OAuth + + def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) + client_options = { + :site => 'http://api.myspace.com', + :access_token_path => '/access_token', + :authorize_path => '/authorize', + :request_token_path => '/request_token', + :http_method => "get" + } + options.merge! :http_method => :get + super(app, :my_space, consumer_key, consumer_secret, client_options, options, &block) + end + + def callback_phase + session['oauth'][name.to_s]['callback_confirmed'] = true + super + end + + def user_data + @access_token.options.merge!({:param_name => 'oauth_token', :mode => :query}) + # response = @access_token.post('/simple/players.info') + # @data ||= MultiJson.decode(response.body) + end + + def request_phase + request_token = consumer.get_request_token(:oauth_callback => callback_url) + session['oauth'] ||= {} + session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} + sleep 1 + if request_token.callback_confirmed? + redirect request_token.authorize_url(options[:authorize_params]) + else + redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url)) + end + + rescue ::Timeout::Error => e + fail!(:timeout, e) + rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e + fail!(:service_unavailable, e) + end + + def consumer + ::OAuth::Consumer.new(consumer_key, consumer_secret, { + :http_method=>"get", + :site=>"http://api.myspace.com", + :request_token_path=>"/request_token", + :access_token_path=>"/access_token", + :authorize_path=>"/authorize" + }) + end + + def user_hash(access_token) + person = JSON.parse( access_token.get("/v2/people/@me/@self?format=json").body )["users"].first + + hash = { + 'id' => person['id'], + 'first_name' => person['first_name'], + 'last_name' => person['last_name'], + 'image' => person["photo_urls"]["large"], + } + end + + end + end +end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/my_space_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/my_space_spec.rb new file mode 100644 index 000000000..9404d76f1 --- /dev/null +++ b/oa-oauth/spec/omniauth/strategies/oauth/my_space_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe OmniAuth::Strategies::MySpace do + it_should_behave_like "an oauth strategy" +end From a560b515b1329e66b856abf69cf0f3eeb006d4e4 Mon Sep 17 00:00:00 2001 From: bradrobertson Date: Thu, 13 Oct 2011 17:29:00 -0400 Subject: [PATCH 24/45] fix tests --- oa-oauth/lib/omniauth/oauth.rb | 1 + oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb index f0ea01f49..e3b5001dc 100644 --- a/oa-oauth/lib/omniauth/oauth.rb +++ b/oa-oauth/lib/omniauth/oauth.rb @@ -37,6 +37,7 @@ module Strategies autoload :Vimeo, 'omniauth/strategies/oauth/vimeo' autoload :Yahoo, 'omniauth/strategies/oauth/yahoo' autoload :YouTube, 'omniauth/strategies/oauth/you_tube' + autoload :Xing, 'omniauth/strategies/oauth/xing' autoload :OAuth2, 'omniauth/strategies/oauth2' autoload :AngelList, 'omniauth/strategies/oauth2/angellist' diff --git a/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb index 71a80a919..85edc6296 100644 --- a/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb +++ b/oa-oauth/spec/omniauth/strategies/oauth/xing_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe OmniAuth::Strategies::XING do +describe OmniAuth::Strategies::Xing do it_should_behave_like "an oauth strategy" end From a0abb77979e3b3ca3bcb6935435489a73842efe2 Mon Sep 17 00:00:00 2001 From: bradrobertson Date: Thu, 13 Oct 2011 17:42:33 -0400 Subject: [PATCH 25/45] set OAuth header so salesforce user query doesnt error out --- .../omniauth/strategies/oauth2/salesforce.rb | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb b/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb index 978490af9..7372f2691 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb @@ -5,12 +5,22 @@ module Strategies class Salesforce < OmniAuth::Strategies::OAuth2 def initialize(app, client_id=nil, client_secret=nil, options={}, &block) client_options = { - :authorize_url => 'https://login.salesforce.com/services/oauth2/authorize', - :token_url => 'https://login.salesforce.com/services/oauth2/token', + :site => 'https://login.salesforce.com', + :authorize_url => '/services/oauth2/authorize', + :token_url => '/services/oauth2/token', } - options.merge!(:response_type => 'code', :grant_type => 'authorization_code') super(app, :salesforce, client_id, client_secret, client_options, options, &block) end + + def request_phase + options[:response_type] ||= 'code' + super + end + + def callback_phase + options[:grant_type] ||= 'authorization_code' + super + end def auth_hash data = user_data @@ -35,10 +45,12 @@ def auth_hash end def user_data - @data ||= MultiJson.decode(@access_token.get(@access_token['id'])) + @access_token.options[:header_format] = 'OAuth %s' + + @data ||= @access_token.get(@access_token['id']).parsed rescue ::OAuth2::Error => e if e.response.status == 302 - @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) + @data ||= @access_token.get(e.response.headers['location']).parsed else raise e end From 7ea4a471dc0229ce50f1ada30e5af907a3084cdd Mon Sep 17 00:00:00 2001 From: altuure Date: Sat, 15 Oct 2011 21:52:54 +0200 Subject: [PATCH 26/45] gowalla fix --- .../lib/omniauth/strategies/oauth2/gowalla.rb | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb b/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb index 85a4a3a03..a46ae844a 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb @@ -26,6 +26,7 @@ def auth_hash super, { 'uid' => user_data['url'].split('/').last, 'user_info' => user_info, + 'credentials' => {'refresh_token' => @access_token.refresh_token}, 'extra' => { 'user_hash' => user_data, 'refresh_token' => refresh_token, @@ -34,10 +35,22 @@ def auth_hash } ) end - def user_data - @data ||= MultiJson.decode(@access_token.get('/users/me.json')) + puts "user_data" + if(@data.nil?) + opts={ + :raise_errors=>false, + :headers =>{:Accept => 'application/json','X-Gowalla-API-Key'=> self.client_id}, + :params=>{:oauth_token=>@access_token.token} + } + response=@access_token.get('http://api.gowalla.com/users/me',opts) + + @data = MultiJson.decode(response.body) + end + + @data end + def refresh_token @refresh_token ||= @access_token.refresh_token @@ -53,6 +66,7 @@ def request_phase end def user_info + { 'name' => "#{user_data['first_name']} #{user_data['last_name']}", 'nickname' => user_data['username'], @@ -67,6 +81,21 @@ def user_info }, } end + def build_access_token + token=super + ##remove expires_at from token, invalid format + token=::OAuth2::AccessToken.new(token.client,token.token,{:expires_in=>token.expires_in,:refresh_token=>token.refresh_token}.merge(token.params)) + ## if token is expired refresh and again remove expires_at + if token.expired? + token=token.refresh! + token=::OAuth2::AccessToken.new(token.client,token.token,{:expires_in=>token.expires_in,:refresh_token=>token.refresh_token}.merge(token.params)) + end + token + + end + end + + end end From d403418b508ac7a928d2a36368ef5b96a4e6916b Mon Sep 17 00:00:00 2001 From: Phil Spitler Date: Tue, 18 Oct 2011 14:20:13 -0400 Subject: [PATCH 27/45] added authorize_params to monkeypatch in google strategy --- oa-oauth/lib/omniauth/strategies/oauth/google.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/google.rb b/oa-oauth/lib/omniauth/strategies/oauth/google.rb index 6470347cb..54ce692ba 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/google.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/google.rb @@ -59,9 +59,12 @@ def user_hash @user_hash ||= MultiJson.decode(@access_token.get('https://www.google.com/m8/feeds/contacts/default/full?max-results=1&alt=json').body) end - # Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call + # Monkeypatch OmniAuth to pass the scope and authorize_params in the consumer.get_request_token call def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => options[:scope]}) + request_options = {:scope => options[:scope]} + request_options.merge!(options[:authorize_params]) + + request_token = consumer.get_request_token({:oauth_callback => callback_url}, request_options) 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 From 1f280a56ab8a950a6f322baa69466b659d2142ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 19 Oct 2011 10:31:10 +0300 Subject: [PATCH 28/45] Stop swallowing OAuth2::Error when building access token. Otherwise Facebook errors will be raised as an runtime exception which won't be passed by the on_failure callback. --- oa-oauth/lib/omniauth/strategies/oauth2.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2.rb b/oa-oauth/lib/omniauth/strategies/oauth2.rb index ce655d567..7dfb2ea9d 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2.rb @@ -78,8 +78,6 @@ def callback_phase def build_access_token verifier = request.params['code'] client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options)) - rescue ::OAuth2::Error => e - raise e.response.inspect end def auth_hash From 006d3cc01c5509356ed3c05b9e2a8cb0689d0ded Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 19 Oct 2011 16:02:12 +0300 Subject: [PATCH 29/45] make possible to set custom route name for google_oauth2 strategy --- oa-oauth/lib/omniauth/strategies/google_oauth2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb b/oa-oauth/lib/omniauth/strategies/google_oauth2.rb index eb641f55c..9aba105e9 100644 --- a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb +++ b/oa-oauth/lib/omniauth/strategies/google_oauth2.rb @@ -16,7 +16,7 @@ def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) :token_url => '/o/oauth2/token' } - super(app, :google_oauth2, client_id, client_secret, client_options, options, &block) + super(app, (options[:name] || :google_oauth2), client_id, client_secret, client_options, options, &block) end def request_phase From 8b72f2977d1d61bdbeae8cb6e62e3ea1751634ac Mon Sep 17 00:00:00 2001 From: Mark Dodwell Date: Thu, 20 Oct 2011 00:11:30 -0700 Subject: [PATCH 30/45] stop rescuing all OAuth2::Errors and re-raising as RuntimeErrors --- oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb | 4 ---- oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb | 2 -- 2 files changed, 6 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb b/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb index 6bbeb1073..93b8483e9 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb @@ -42,8 +42,6 @@ def user_data @access_token.options[:mode] = :query @access_token.options[:param_name] = 'access_token' @data ||= @access_token.get('/me').parsed - rescue ::OAuth2::Error => e - raise e.response.inspect end def request_phase @@ -60,8 +58,6 @@ def build_access_token else super end - rescue ::OAuth2::Error => e - raise e.response.inspect end def facebook_session diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb index 2c6e00710..5eb56a6d1 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/yammer.rb @@ -49,8 +49,6 @@ def build_access_token temp_access_token = client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options)) token = eval(temp_access_token.token)['token'] @access_token = ::OAuth2::AccessToken.new(client, token, temp_access_token.params) - rescue ::OAuth2::Error => e - raise e.response.inspect end def user_hash From 729b892c6bba50bc4aa99450e11a682f0f904851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krzyz=CC=87anowski?= Date: Thu, 20 Oct 2011 14:42:40 +0200 Subject: [PATCH 31/45] fixed thirty_seven_signals strategy --- oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb b/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb index d783a1950..e10b6d9d6 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb @@ -25,7 +25,7 @@ def auth_hash end def user_data - @data ||= MultiJson.decode(@access_token.get('/authorization.json')) + @data ||= @access_token.get('https://launchpad.37signals.com/authorization.json').parsed end def user_info From cf5dae6baed1f305cd1fd778f5a051643d7ec11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Scho=CC=88n?= Date: Thu, 20 Oct 2011 18:19:52 +0200 Subject: [PATCH 32/45] add email address to user_info hash in xing strategy --- oa-oauth/lib/omniauth/strategies/oauth/xing.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/xing.rb b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb index 9693bf95d..35db4ef43 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/xing.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb @@ -39,6 +39,7 @@ def user_hash(access_token) 'first_name' => person['first_name'], 'last_name' => person['last_name'], 'image' => person["photo_urls"]["large"], + 'email' => person["active_email"], } end From b15870d4a7b34b3b4a647316365c809151a48a38 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 20 Oct 2011 12:26:08 -0700 Subject: [PATCH 33/45] Bump version to 0.3.1 --- lib/omniauth/version.rb | 2 +- oa-basic/lib/omniauth/version.rb | 2 +- oa-core/lib/omniauth/version.rb | 2 +- oa-enterprise/lib/omniauth/version.rb | 2 +- oa-more/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/version.rb | 2 +- oa-openid/lib/omniauth/version.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/omniauth/version.rb b/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/lib/omniauth/version.rb +++ b/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-basic/lib/omniauth/version.rb b/oa-basic/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-basic/lib/omniauth/version.rb +++ b/oa-basic/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-enterprise/lib/omniauth/version.rb +++ b/oa-enterprise/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-more/lib/omniauth/version.rb b/oa-more/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-more/lib/omniauth/version.rb +++ b/oa-more/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-openid/lib/omniauth/version.rb b/oa-openid/lib/omniauth/version.rb index 64dd11302..46bf900c2 100644 --- a/oa-openid/lib/omniauth/version.rb +++ b/oa-openid/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 + PATCH = 1 end unless defined?(::OmniAuth::Version::PRE) PRE = nil From 05a76deff74d23f72081a571df458b5809bdd5fc Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 20 Oct 2011 16:15:58 -0700 Subject: [PATCH 34/45] Bump version to 0.3.2 --- lib/omniauth/version.rb | 2 +- oa-basic/lib/omniauth/version.rb | 2 +- oa-core/lib/omniauth/version.rb | 2 +- oa-enterprise/lib/omniauth/version.rb | 2 +- oa-more/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/version.rb | 2 +- oa-openid/lib/omniauth/version.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/omniauth/version.rb b/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/lib/omniauth/version.rb +++ b/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-basic/lib/omniauth/version.rb b/oa-basic/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-basic/lib/omniauth/version.rb +++ b/oa-basic/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-enterprise/lib/omniauth/version.rb +++ b/oa-enterprise/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-more/lib/omniauth/version.rb b/oa-more/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-more/lib/omniauth/version.rb +++ b/oa-more/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil diff --git a/oa-openid/lib/omniauth/version.rb b/oa-openid/lib/omniauth/version.rb index 46bf900c2..2938a2616 100644 --- a/oa-openid/lib/omniauth/version.rb +++ b/oa-openid/lib/omniauth/version.rb @@ -7,7 +7,7 @@ module Version MINOR = 3 end unless defined?(::OmniAuth::Version::PATCH) - PATCH = 1 + PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) PRE = nil From 3aff8a3d71a5c968f558172750a2a20165d77bc5 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 20 Oct 2011 16:20:31 -0700 Subject: [PATCH 35/45] Make release script compatible with Ruby 1.8 --- tasks/all.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/all.rb b/tasks/all.rb index 77f745403..b308368db 100644 --- a/tasks/all.rb +++ b/tasks/all.rb @@ -34,7 +34,7 @@ def version task :build => :clean do cd dir sh "gem build #{gemspec}" - mkdir_p package_dir unless Dir.exists?(package_dir) + mkdir_p package_dir unless File.directory?(package_dir) mv gem, "#{package_dir}/#{gem}" end From efa1948215cb7f4b2616df42b72064368196a1b0 Mon Sep 17 00:00:00 2001 From: Benny Wong Date: Thu, 20 Oct 2011 21:05:02 -0400 Subject: [PATCH 36/45] Make instagram strategy fetch user data from full url. Fixes #431 --- oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb b/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb index 67c027d82..cbab61ee5 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb @@ -43,7 +43,7 @@ def callback_phase def user_data @access_token.options.merge!({:param_name => 'access_token', :mode => :query}) - @data ||= MultiJson.decode(@access_token.get('/v1/users/self')) + @data ||= @access_token.get('https://api.instagram.com/v1/users/self').parsed end def user_info From 0743594cf8cdd15d1a523ddfa457fd82a6a4360b Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Fri, 28 Oct 2011 12:50:42 -0700 Subject: [PATCH 37/45] update version to 0.3.2.1.copious --- oa-core/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 0532ca341..aec215ba7 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) - PRE = "3.copious" + PRE = "1.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 0532ca341..aec215ba7 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) - PRE = "3.copious" + PRE = "1.copious" end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') From 807d4560bca1f1dbeacc94f9f60831721cd8114a Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Fri, 28 Oct 2011 17:16:09 -0700 Subject: [PATCH 38/45] patch for copious version --- oa-oauth/oa-oauth.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 555e02c1c..0b165e0ba 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'faraday', '~> 0.7.3' gem.add_dependency 'multi_json', '~> 1.0.0' gem.add_dependency 'multi_xml', '~> 0.4.0' - gem.add_dependency 'oa-core', OmniAuth::Version::STRING + gem.add_dependency 'oa-core', ">= #{OmniAuth::Version::STRING}" gem.add_dependency 'oauth', '~> 0.4.0' gem.add_dependency 'oauth2', '~> 0.5.0' gem.add_development_dependency 'evernote', '~> 1.0' From 6378a03f48f527d7aa53fa2bba9290dc8bb4b7e2 Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Mon, 31 Oct 2011 11:02:39 -0700 Subject: [PATCH 39/45] Remove copious-specific versioning --- oa-core/lib/omniauth/version.rb | 5 +---- oa-oauth/lib/omniauth/version.rb | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index aec215ba7..fa89518b5 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -9,11 +9,8 @@ module Version unless defined?(::OmniAuth::Version::PATCH) PATCH = 2 end - unless defined?(::OmniAuth::Version::PRE) - PRE = "1.copious" - end unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + STRING = [MAJOR, MINOR, PATCH].compact.join('.') end end end diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index aec215ba7..fa89518b5 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -9,11 +9,8 @@ module Version unless defined?(::OmniAuth::Version::PATCH) PATCH = 2 end - unless defined?(::OmniAuth::Version::PRE) - PRE = "1.copious" - end unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') + STRING = [MAJOR, MINOR, PATCH].compact.join('.') end end end From 9126d827aa75cc80a61e42dfa8f3727512727c2e Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Mon, 31 Oct 2011 11:09:04 -0700 Subject: [PATCH 40/45] Revert copious-specific version changes --- oa-core/lib/omniauth/version.rb | 5 ++++- oa-oauth/lib/omniauth/version.rb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index fa89518b5..695c39580 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -9,8 +9,11 @@ module Version unless defined?(::OmniAuth::Version::PATCH) PATCH = 2 end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH].compact.join('.') + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') end end end diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index fa89518b5..695c39580 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -9,8 +9,11 @@ module Version unless defined?(::OmniAuth::Version::PATCH) PATCH = 2 end + unless defined?(::OmniAuth::Version::PRE) + PRE = nil + end unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH].compact.join('.') + STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') end end end From a1d395390ab66a13c20a2b8e669d92ef8fb7c68e Mon Sep 17 00:00:00 2001 From: David LaMacchia Date: Mon, 31 Oct 2011 11:11:25 -0700 Subject: [PATCH 41/45] Fix whitespace issues --- oa-core/lib/omniauth/version.rb | 2 +- oa-oauth/lib/omniauth/oauth.rb | 3 +++ oa-oauth/lib/omniauth/version.rb | 2 +- oa-oauth/oa-oauth.gemspec | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb index 695c39580..2938a2616 100644 --- a/oa-core/lib/omniauth/version.rb +++ b/oa-core/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) - PRE = nil + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb index 1136f61d6..a62cda75f 100644 --- a/oa-oauth/lib/omniauth/oauth.rb +++ b/oa-oauth/lib/omniauth/oauth.rb @@ -68,7 +68,10 @@ module Strategies autoload :Vkontakte, 'omniauth/strategies/oauth2/vkontakte' autoload :WePay, 'omniauth/strategies/oauth2/we_pay' autoload :Yammer, 'omniauth/strategies/oauth2/yammer' + + autoload :XAuth, 'omniauth/strategies/xauth' autoload :Instapaper, 'omniauth/strategies/xauth/instapaper' + end end diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb index 695c39580..2938a2616 100644 --- a/oa-oauth/lib/omniauth/version.rb +++ b/oa-oauth/lib/omniauth/version.rb @@ -10,7 +10,7 @@ module Version PATCH = 2 end unless defined?(::OmniAuth::Version::PRE) - PRE = nil + PRE = nil end unless defined?(::OmniAuth::Version::STRING) STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec index 0b165e0ba..555e02c1c 100644 --- a/oa-oauth/oa-oauth.gemspec +++ b/oa-oauth/oa-oauth.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'faraday', '~> 0.7.3' gem.add_dependency 'multi_json', '~> 1.0.0' gem.add_dependency 'multi_xml', '~> 0.4.0' - gem.add_dependency 'oa-core', ">= #{OmniAuth::Version::STRING}" + gem.add_dependency 'oa-core', OmniAuth::Version::STRING gem.add_dependency 'oauth', '~> 0.4.0' gem.add_dependency 'oauth2', '~> 0.5.0' gem.add_development_dependency 'evernote', '~> 1.0' From 19a9497744ca8f0290f63201b1978119dc607629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Scho=CC=88n?= Date: Wed, 2 Nov 2011 12:08:57 +0100 Subject: [PATCH 42/45] oauth specification fix for xing strategy is no longer needed https://www.xing.com/v1/changelog --- oa-oauth/lib/omniauth/strategies/oauth/xing.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/xing.rb b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb index 35db4ef43..b7709db8d 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/xing.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/xing.rb @@ -15,11 +15,6 @@ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) super(app, :xing, consumer_key, consumer_secret, client_options, options, &block) end - def callback_phase - session['oauth'][name.to_s]['callback_confirmed'] = true - super - end - def auth_hash hash = user_hash(@access_token) @@ -45,4 +40,4 @@ def user_hash(access_token) end end -end \ No newline at end of file +end From bb9df6276c8df5182427ccd9f205d0f7aa024fc7 Mon Sep 17 00:00:00 2001 From: ufssf Date: Sun, 6 Nov 2011 11:07:54 +0900 Subject: [PATCH 43/45] some fixes for mixi strategy --- oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb b/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb index af4ee7edc..4dab88f6f 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb @@ -23,7 +23,9 @@ def auth_hash super, { 'uid' => user_data['entry']['id'], 'user_info' => user_info, - 'credentials' => {'refresh_token' => @access_token.refresh_token}, + 'credentials' => {'refresh_token' => @access_token.refresh_token, + 'expires_in' => @access_token.expires_in + }, 'extra' => { 'user_hash' => user_data['entry'], }, @@ -32,10 +34,12 @@ def auth_hash end def user_data + @access_token.options[:mode] = :query + @access_token.options[:param_name] = 'oauth_token' @data ||= MultiJson.decode(@access_token.get( 'http://api.mixi-platform.com/2/people/@me/@self', {'oauth_token' => @access_token.token} - )) + ).body) end def request_phase From 959c85049c5317575adc106f933ac3bc48eb55f3 Mon Sep 17 00:00:00 2001 From: Brian Miller Date: Thu, 17 Nov 2011 14:00:07 -0800 Subject: [PATCH 44/45] Dropbox requires use of api version 1 --- oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb b/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb index 58b60535f..7e1690c73 100644 --- a/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb +++ b/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb @@ -6,10 +6,10 @@ module Strategies class Dropbox < OmniAuth::Strategies::OAuth def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) client_options = { - :authorize_url => 'https://www.dropbox.com/0/oauth/authorize', - :access_token_url => 'https://api.dropbox.com/0/oauth/access_token', + :authorize_url => 'https://www.dropbox.com/1/oauth/authorize', + :access_token_url => 'https://api.dropbox.com/1/oauth/access_token', :proxy => ENV['HTTP_PROXY'] || ENV['http_proxy'], - :request_token_url => 'https://api.dropbox.com/0/oauth/request_token', + :request_token_url => 'https://api.dropbox.com/1/oauth/request_token', :site => 'https://api.dropbox.com', } super(app, :dropbox, consumer_key, consumer_secret, client_options, options, &block) @@ -25,7 +25,7 @@ def auth_hash end def user_data - @data ||= MultiJson.decode(@access_token.get('/0/account/info').body) + @data ||= MultiJson.decode(@access_token.get('/1/account/info').body) end def user_info From a900deff411d9e3079c8bdd4c165fe9eb08a6bfa Mon Sep 17 00:00:00 2001 From: Ryan Abbott Date: Thu, 8 Mar 2012 23:56:31 -0800 Subject: [PATCH 45/45] Added support for Mendeley oauth authentication --- .../lib/omniauth/strategies/oauth/mendeley.rb | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 oa-oauth/lib/omniauth/strategies/oauth/mendeley.rb diff --git a/oa-oauth/lib/omniauth/strategies/oauth/mendeley.rb b/oa-oauth/lib/omniauth/strategies/oauth/mendeley.rb new file mode 100644 index 000000000..77a8d8494 --- /dev/null +++ b/oa-oauth/lib/omniauth/strategies/oauth/mendeley.rb @@ -0,0 +1,51 @@ +require "omniauth/oauth" +require "multi_json" + +module OmniAuth + module Strategies + # Authenticate to Mendeley via OAuth and retrieve basic user information. + # + # Usage: + # use OmniAuth::Strategies::Mendeley, 'consumer_key', 'consumer_secret' + class Mendeley < OmniAuth::Strategies::OAuth + def initialize(app, consumer_key = nil, consumer_secret = nil, &block) + client_options = { + :site => "http://www.mendeley.com", + :request_token_path => "http://www.mendeley.com/oauth/request_token/", + :access_token_path => "http://www.mendeley.com/oauth/access_token/", + :authorize_url => "http://www.mendeley.com/oauth/authorize/", + :http_method => :get, + :scheme => :query_string + } + + super(app, :mendeley, consumer_key, consumer_secret, client_options, &block) + end + + def auth_hash + OmniAuth::Utils.deep_merge( + super, { + "uid" => user_data["main"]["profile_id"], + "user_info" => user_info, + } + ) + end + + def user_data + @data ||= MultiJson.decode(@access_token.get("/oapi/profiles/info/me").body) + end + + def user_info + { + "name" => user_data["main"]["name"], + "uid" => user_data["main"]["profile_id"] + } + end + + def callback_phase + session["oauth"][name.to_s]["callback_confirmed"] = true + + super + end + end + end +end \ No newline at end of file