oa-oauth 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -0,0 +1,35 @@
1
+ = OmniAuth::OAuth
2
+
3
+ OAuth 1.0 and 2.0 strategies for the OmniAuth gem.
4
+
5
+ == Installation
6
+
7
+ To get just OAuth functionality:
8
+
9
+ gem install oa-oauth
10
+
11
+ For the full auth suite:
12
+
13
+ gem install omniauth
14
+
15
+ == Stand-Alone Example
16
+
17
+ Use the strategy as a middleware in your application:
18
+
19
+ require 'omniauth/oauth'
20
+
21
+ use OmniAuth::Strategies::Twitter, 'consumer_key', 'consumer_secret'
22
+
23
+ Then simply direct users to '/auth/twitter' to have them authenticate via Twitter.
24
+
25
+ == OmniAuth Builder
26
+
27
+ If you want to allow multiple providers, use the OmniAuth Builder:
28
+
29
+ require 'omniauth/oauth'
30
+
31
+ use OmniAuth::Builder do
32
+ provider :twitter, 'consumer_key', 'consumer_secret'
33
+ provider :facebook, 'app_id', 'app_secret'
34
+ end
35
+
@@ -1,10 +1,14 @@
1
- require 'oauth'
2
- require 'oauth2'
3
-
4
1
  require 'omniauth/core'
5
- require 'omniauth/strategies/oauth'
6
- require 'omniauth/strategies/twitter'
7
- require 'omniauth/strategies/linked_in'
8
- require 'omniauth/strategies/oauth2'
9
- require 'omniauth/strategies/facebook'
10
- require 'omniauth/strategies/github'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ autoload :OAuth, 'omniauth/strategies/oauth'
6
+ autoload :OAuth2, 'omniauth/strategies/oauth2'
7
+
8
+ autoload :Twitter, 'omniauth/strategies/twitter'
9
+ autoload :LinkedIn, 'omniauth/strategies/linked_in'
10
+ autoload :Facebook, 'omniauth/strategies/facebook'
11
+ autoload :GitHub, 'omniauth/strategies/github'
12
+ autoload :ThirtySevenSignals, 'omniauth/strategies/thirty_seven_signals'
13
+ end
14
+ end
@@ -1,4 +1,5 @@
1
- require 'json'
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
@@ -20,7 +21,7 @@ module OmniAuth
20
21
  end
21
22
 
22
23
  def user_data
23
- @data ||= JSON.parse(@access_token.get('/me'))
24
+ @data ||= MultiJson.decode(@access_token.get('/me'))
24
25
  end
25
26
 
26
27
  def request_phase(options = {})
@@ -50,4 +51,4 @@ module OmniAuth
50
51
  end
51
52
  end
52
53
  end
53
- end
54
+ end
@@ -1,4 +1,5 @@
1
- require 'json'
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
@@ -11,7 +12,7 @@ module OmniAuth
11
12
  end
12
13
 
13
14
  def user_data
14
- @data ||= JSON.parse(@access_token.get('/api/v2/json/user/show'))['user']
15
+ @data ||= MultiJson.decode(@access_token.get('/api/v2/json/user/show'))['user']
15
16
  end
16
17
 
17
18
  def user_info
@@ -35,4 +36,4 @@ module OmniAuth
35
36
  end
36
37
  end
37
38
  end
38
- end
39
+ end
@@ -1,6 +1,5 @@
1
- require 'omniauth/core'
2
- require 'omniauth/strategies/oauth'
3
1
  require 'nokogiri'
2
+ require 'omniauth/oauth'
4
3
 
5
4
  module OmniAuth
6
5
  module Strategies
@@ -33,9 +32,9 @@ module OmniAuth
33
32
  'location' => person.xpath('location/name').text,
34
33
  'image' => person.xpath('picture-url').text,
35
34
  'description' => person.xpath('headline').text,
36
- 'urls' => person.css('member-url-resources member-url').inject({}) do |hash,element|
37
- hash[element.xpath('name').text] = element.xpath('url').text
38
- hash
35
+ 'urls' => person.css('member-url-resources member-url').inject({}) do |h,element|
36
+ h[element.xpath('name').text] = element.xpath('url').text
37
+ h
39
38
  end
40
39
  }
41
40
 
@@ -44,4 +43,4 @@ module OmniAuth
44
43
  end
45
44
  end
46
45
  end
47
- end
46
+ end
@@ -1,10 +1,12 @@
1
+ require 'oauth'
2
+ require 'omniauth/oauth'
3
+
1
4
  module OmniAuth
2
5
  module Strategies
3
6
  class OAuth
4
7
  include OmniAuth::Strategy
5
8
 
6
9
  def initialize(app, name, consumer_key, consumer_secret, options = {})
7
- require 'oauth'
8
10
  super
9
11
  @consumer = ::OAuth::Consumer.new(consumer_key, consumer_secret, options)
10
12
  end
@@ -45,4 +47,4 @@ module OmniAuth
45
47
  end
46
48
  end
47
49
  end
48
- end
50
+ end
@@ -1,5 +1,7 @@
1
1
  require 'cgi'
2
2
  require 'uri'
3
+ require 'oauth2'
4
+ require 'omniauth/oauth'
3
5
 
4
6
  module OmniAuth
5
7
  module Strategies
@@ -12,15 +14,17 @@ module OmniAuth
12
14
  @client = ::OAuth2::Client.new(client_id, client_secret, options)
13
15
  end
14
16
 
15
- attr_accessor :client_id, :client_secret, :options
17
+ protected
18
+
19
+ attr_accessor :client
16
20
 
17
21
  def request_phase(options = {})
18
- redirect @client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options))
22
+ redirect client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options))
19
23
  end
20
24
 
21
25
  def callback_phase
22
26
  verifier = request.params['code']
23
- @access_token = @client.web_server.get_access_token(verifier, :redirect_uri => callback_url)
27
+ @access_token = client.web_server.get_access_token(verifier, :redirect_uri => callback_url)
24
28
  super
25
29
  rescue ::OAuth2::HTTPError => e
26
30
  fail!(:invalid_credentials)
@@ -35,4 +39,4 @@ module OmniAuth
35
39
  end
36
40
  end
37
41
  end
38
- end
42
+ end
@@ -0,0 +1,38 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class ThirtySevenSignals < OAuth2
7
+ def initialize(app, app_id, app_secret, options = {})
8
+ options[:site] = 'https://launchpad.37signals.com/'
9
+ options[:authorize_path] = '/authorization/new'
10
+ options[:access_token_path] = '/authorization/token'
11
+ super(app, :thirty_seven_signals, app_id, app_secret, options)
12
+ end
13
+
14
+ def user_data
15
+ @data ||= MultiJson.decode(@access_token.get('/authorization.json'))
16
+ end
17
+
18
+ def user_info
19
+ {
20
+ 'email' => user_data['identity']['email_address'],
21
+ 'first_name' => user_data['identity']['first_name'],
22
+ 'last_name' => user_data['identity']['last_name'],
23
+ 'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip
24
+ }
25
+ end
26
+
27
+ def auth_hash
28
+ OmniAuth::Utils.deep_merge(super, {
29
+ 'uid' => user_data['identity']['id'],
30
+ 'user_info' => user_info,
31
+ 'extra' => {
32
+ 'accounts' => user_data['accounts']
33
+ }
34
+ })
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,6 +1,5 @@
1
- require 'omniauth/core'
2
- require 'omniauth/strategies/oauth'
3
- require 'json'
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
4
3
 
5
4
  module OmniAuth
6
5
  module Strategies
@@ -41,8 +40,8 @@ module OmniAuth
41
40
  end
42
41
 
43
42
  def user_hash
44
- @user_hash ||= JSON.parse(@access_token.get('/1/account/verify_credentials.json').body)
43
+ @user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body)
45
44
  end
46
45
  end
47
46
  end
48
- end
47
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-oauth
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Bleigh
@@ -14,121 +15,183 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-29 00:00:00 -04:00
18
+ date: 2010-08-16 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ hash: 23
28
+ segments:
29
+ - 0
30
+ - 0
31
+ - 4
32
+ version: 0.0.4
33
+ requirement: *id001
21
34
  name: oa-core
22
35
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
36
+ type: :runtime
37
+ - !ruby/object:Gem::Dependency
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
24
40
  requirements:
25
41
  - - ~>
26
42
  - !ruby/object:Gem::Version
43
+ hash: 27
27
44
  segments:
28
45
  - 0
29
46
  - 0
30
- - 0
31
- version: 0.0.0
47
+ - 2
48
+ version: 0.0.2
49
+ requirement: *id002
50
+ name: multi_json
51
+ prerelease: false
32
52
  type: :runtime
33
- version_requirements: *id001
34
53
  - !ruby/object:Gem::Dependency
35
- name: oauth
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
38
56
  requirements:
39
- - - ">="
57
+ - - ~>
40
58
  - !ruby/object:Gem::Version
59
+ hash: 3
41
60
  segments:
42
- - 0
43
- version: "0"
61
+ - 1
62
+ - 4
63
+ - 2
64
+ version: 1.4.2
65
+ requirement: *id003
66
+ name: nokogiri
67
+ prerelease: false
44
68
  type: :runtime
45
- version_requirements: *id002
46
69
  - !ruby/object:Gem::Dependency
47
- name: oauth2
48
- prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ none: false
50
72
  requirements:
51
- - - ">="
73
+ - - ~>
52
74
  - !ruby/object:Gem::Version
75
+ hash: 15
53
76
  segments:
54
77
  - 0
55
- version: "0"
78
+ - 4
79
+ - 0
80
+ version: 0.4.0
81
+ requirement: *id004
82
+ name: oauth
83
+ prerelease: false
56
84
  type: :runtime
57
- version_requirements: *id003
58
85
  - !ruby/object:Gem::Dependency
59
- name: nokogiri
60
- prerelease: false
61
- requirement: &id004 !ruby/object:Gem::Requirement
86
+ version_requirements: &id005 !ruby/object:Gem::Requirement
87
+ none: false
62
88
  requirements:
63
- - - ">="
89
+ - - ~>
64
90
  - !ruby/object:Gem::Version
91
+ hash: 11
65
92
  segments:
66
93
  - 0
67
- version: "0"
94
+ - 0
95
+ - 10
96
+ version: 0.0.10
97
+ requirement: *id005
98
+ name: oauth2
99
+ prerelease: false
68
100
  type: :runtime
69
- version_requirements: *id004
70
101
  - !ruby/object:Gem::Dependency
71
- name: json
72
- prerelease: false
73
- requirement: &id005 !ruby/object:Gem::Requirement
102
+ version_requirements: &id006 !ruby/object:Gem::Requirement
103
+ none: false
74
104
  requirements:
75
105
  - - ">="
76
106
  - !ruby/object:Gem::Version
107
+ hash: 3
77
108
  segments:
78
109
  - 0
79
110
  version: "0"
80
- type: :runtime
81
- version_requirements: *id005
82
- - !ruby/object:Gem::Dependency
83
- name: rspec
111
+ requirement: *id006
112
+ name: rake
84
113
  prerelease: false
85
- requirement: &id006 !ruby/object:Gem::Requirement
114
+ type: :development
115
+ - !ruby/object:Gem::Dependency
116
+ version_requirements: &id007 !ruby/object:Gem::Requirement
117
+ none: false
86
118
  requirements:
87
- - - ">="
119
+ - - ~>
88
120
  - !ruby/object:Gem::Version
121
+ hash: 15
89
122
  segments:
90
- - 1
91
- - 2
92
- - 9
93
- version: 1.2.9
123
+ - 0
124
+ - 0
125
+ - 8
126
+ version: 0.0.8
127
+ requirement: *id007
128
+ name: mg
129
+ prerelease: false
94
130
  type: :development
95
- version_requirements: *id006
96
131
  - !ruby/object:Gem::Dependency
97
- name: webmock
98
- prerelease: false
99
- requirement: &id007 !ruby/object:Gem::Requirement
132
+ version_requirements: &id008 !ruby/object:Gem::Requirement
133
+ none: false
100
134
  requirements:
101
- - - ">="
135
+ - - ~>
102
136
  - !ruby/object:Gem::Version
137
+ hash: 27
103
138
  segments:
139
+ - 1
140
+ - 3
104
141
  - 0
105
- version: "0"
142
+ version: 1.3.0
143
+ requirement: *id008
144
+ name: rspec
145
+ prerelease: false
106
146
  type: :development
107
- version_requirements: *id007
108
147
  - !ruby/object:Gem::Dependency
109
- name: rack-test
148
+ version_requirements: &id009 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ hash: 19
154
+ segments:
155
+ - 1
156
+ - 3
157
+ - 4
158
+ version: 1.3.4
159
+ requirement: *id009
160
+ name: webmock
110
161
  prerelease: false
111
- requirement: &id008 !ruby/object:Gem::Requirement
162
+ type: :development
163
+ - !ruby/object:Gem::Dependency
164
+ version_requirements: &id010 !ruby/object:Gem::Requirement
165
+ none: false
112
166
  requirements:
113
- - - ">="
167
+ - - ~>
114
168
  - !ruby/object:Gem::Version
169
+ hash: 3
115
170
  segments:
116
171
  - 0
117
- version: "0"
172
+ - 5
173
+ - 4
174
+ version: 0.5.4
175
+ requirement: *id010
176
+ name: rack-test
177
+ prerelease: false
118
178
  type: :development
119
- version_requirements: *id008
120
179
  - !ruby/object:Gem::Dependency
121
- name: mg
122
- prerelease: false
123
- requirement: &id009 !ruby/object:Gem::Requirement
180
+ version_requirements: &id011 !ruby/object:Gem::Requirement
181
+ none: false
124
182
  requirements:
125
- - - ">="
183
+ - - ~>
126
184
  - !ruby/object:Gem::Version
185
+ hash: 1
127
186
  segments:
128
- - 0
129
- version: "0"
187
+ - 1
188
+ - 4
189
+ - 3
190
+ version: 1.4.3
191
+ requirement: *id011
192
+ name: json
193
+ prerelease: false
130
194
  type: :development
131
- version_requirements: *id009
132
195
  description: OAuth strategies for OmniAuth.
133
196
  email: michael@intridea.com
134
197
  executables: []
@@ -144,6 +207,7 @@ files:
144
207
  - lib/omniauth/strategies/linked_in.rb
145
208
  - lib/omniauth/strategies/oauth.rb
146
209
  - lib/omniauth/strategies/oauth2.rb
210
+ - lib/omniauth/strategies/thirty_seven_signals.rb
147
211
  - lib/omniauth/strategies/twitter.rb
148
212
  - README.rdoc
149
213
  - LICENSE.rdoc
@@ -158,23 +222,27 @@ rdoc_options: []
158
222
  require_paths:
159
223
  - lib
160
224
  required_ruby_version: !ruby/object:Gem::Requirement
225
+ none: false
161
226
  requirements:
162
227
  - - ">="
163
228
  - !ruby/object:Gem::Version
229
+ hash: 3
164
230
  segments:
165
231
  - 0
166
232
  version: "0"
167
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
+ none: false
168
235
  requirements:
169
236
  - - ">="
170
237
  - !ruby/object:Gem::Version
238
+ hash: 3
171
239
  segments:
172
240
  - 0
173
241
  version: "0"
174
242
  requirements: []
175
243
 
176
244
  rubyforge_project:
177
- rubygems_version: 1.3.6
245
+ rubygems_version: 1.3.7
178
246
  signing_key:
179
247
  specification_version: 3
180
248
  summary: OAuth strategies for OmniAuth.