oa-oauth 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ module OmniAuth
17
17
  autoload :TripIt, 'omniauth/strategies/trip_it'
18
18
  autoload :Dopplr, 'omniauth/strategies/dopplr'
19
19
  autoload :Meetup, 'omniauth/strategies/meetup'
20
+ autoload :Salesforce, 'omniauth/strategies/salesforce'
20
21
  autoload :SoundCloud, 'omniauth/strategies/sound_cloud'
21
22
  autoload :SmugMug, 'omniauth/strategies/smug_mug'
22
23
  autoload :Goodreads, 'omniauth/strategies/goodreads'
@@ -1,3 +1,4 @@
1
+ require 'multi_json'
1
2
  require 'oauth'
2
3
  require 'omniauth/oauth'
3
4
 
@@ -13,6 +14,7 @@ module OmniAuth
13
14
  super
14
15
  self.options[:open_timeout] ||= 30
15
16
  self.options[:read_timeout] ||= 30
17
+ self.options[:authorize_params] = options[:authorize_params] || {}
16
18
  end
17
19
 
18
20
  def consumer
@@ -32,9 +34,9 @@ module OmniAuth
32
34
  r = Rack::Response.new
33
35
 
34
36
  if request_token.callback_confirmed?
35
- r.redirect(request_token.authorize_url)
37
+ r.redirect(request_token.authorize_url(options[:authorize_params]))
36
38
  else
37
- r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
39
+ r.redirect(request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url)))
38
40
  end
39
41
 
40
42
  r.finish
@@ -0,0 +1,44 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Salesforce < OmniAuth::Strategies::OAuth2
6
+ def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
7
+ client_options = {
8
+ :site => 'https://login.salesforce.com',
9
+ :authorize_path => '/services/oauth2/authorize',
10
+ :access_token_path => '/services/oauth2/token'
11
+ }
12
+
13
+ options.merge!(:response_type => 'code', :grant_type => 'authorization_code')
14
+
15
+ super(app, :salesforce, consumer_key, consumer_secret, client_options, options, &block)
16
+ end
17
+
18
+ def auth_hash
19
+ data = user_data
20
+ OmniAuth::Utils.deep_merge(super, {
21
+ 'uid' => @access_token['id'],
22
+ 'credentials' => {
23
+ 'instance_url' => @access_token['instance_url']
24
+ },
25
+ 'extra' => {'user_hash' => data},
26
+ 'user_info' => {
27
+ 'email' => data['email'],
28
+ 'name' => data['display_name']
29
+ }
30
+ })
31
+ end
32
+
33
+ def user_data
34
+ @data ||= MultiJson.decode(@access_token.get(@access_token['id']))
35
+ rescue ::OAuth2::HTTPError => e
36
+ if e.response.status == 302
37
+ @data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
38
+ else
39
+ raise e
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -20,6 +20,7 @@ module OmniAuth
20
20
  :site => 'https://api.twitter.com'
21
21
  }
22
22
 
23
+ options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true
23
24
  client_options[:authorize_path] = '/oauth/authenticate' unless options[:sign_in] == false
24
25
  super(app, :twitter, consumer_key, consumer_secret, client_options, options)
25
26
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-oauth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-11 00:00:00 -06:00
13
+ date: 2011-04-05 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.2.0
23
+ version: 0.2.1
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: *id001
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 0.1.1
67
+ version: 0.2.0
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: *id005
@@ -178,6 +178,7 @@ files:
178
178
  - lib/omniauth/strategies/netflix.rb
179
179
  - lib/omniauth/strategies/oauth.rb
180
180
  - lib/omniauth/strategies/oauth2.rb
181
+ - lib/omniauth/strategies/salesforce.rb
181
182
  - lib/omniauth/strategies/smug_mug.rb
182
183
  - lib/omniauth/strategies/sound_cloud.rb
183
184
  - lib/omniauth/strategies/thirty_seven_signals.rb
@@ -205,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
206
  requirements:
206
207
  - - ">="
207
208
  - !ruby/object:Gem::Version
208
- hash: -2125816653041836513
209
+ hash: -1141434774696898432
209
210
  segments:
210
211
  - 0
211
212
  version: "0"
@@ -214,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
215
  requirements:
215
216
  - - ">="
216
217
  - !ruby/object:Gem::Version
217
- hash: -2125816653041836513
218
+ hash: -1141434774696898432
218
219
  segments:
219
220
  - 0
220
221
  version: "0"