oauth 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +10 -8
- data/lib/oauth/client/helper.rb +8 -2
- data/lib/oauth/consumer.rb +43 -10
- data/lib/oauth/tokens/request_token.rb +10 -3
- data/lib/oauth/version.rb +1 -1
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56561f5f687d933f2683b93c5d7a426c3202da9b6659cc69d8ef43c36766bb9b
|
4
|
+
data.tar.gz: 71d7d2890d9b2261b85752ba2844eb96d7538a5121b9b72bcef3d00347e91bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bbb7ec6242a2fdeadcae61c5279d42e00d9b29318511b80ea5a0215b8cdfba15c10be2ef0abb74bb21038acff22e27ef59125a8148ab28817f79d89b792707d
|
7
|
+
data.tar.gz: 3ad73ee2f52bf3507b274e923fe2352f7e5cda860e8765a9b062f33abfbc61909e5ff15ced0ce7d5aa66489f002f056f2fbb720f70b179c6eb729c52b7ce76e1
|
data/README.rdoc
CHANGED
@@ -28,26 +28,28 @@ As a matter of fact it has been pulled out from an OAuth Rails GEM (https://ruby
|
|
28
28
|
|
29
29
|
We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)
|
30
30
|
|
31
|
-
|
31
|
+
callback_url = "http://127.0.0.1:3000/oauth/callback"
|
32
32
|
|
33
|
-
Create a new
|
33
|
+
Create a new `OAuth::Consumer` instance by passing it a configuration hash:
|
34
34
|
|
35
|
-
|
35
|
+
oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
|
36
36
|
|
37
37
|
Start the process by requesting a token
|
38
38
|
|
39
|
-
|
39
|
+
request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
|
40
40
|
|
41
41
|
session[:token] = request_token.token
|
42
42
|
session[:token_secret] = request_token.secret
|
43
|
-
redirect_to
|
43
|
+
redirect_to request_token.authorize_url(:oauth_callback => callback_url)
|
44
44
|
|
45
45
|
When user returns create an access_token
|
46
46
|
|
47
47
|
hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
|
48
|
-
request_token = OAuth::RequestToken.from_hash(
|
49
|
-
|
50
|
-
|
48
|
+
request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
|
49
|
+
access_token = request_token.get_access_token
|
50
|
+
# For 3-legged authorization, flow oauth_verifier is passed as param in callback
|
51
|
+
# access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
|
52
|
+
@photos = access_token.get('/photos.xml')
|
51
53
|
|
52
54
|
Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.
|
53
55
|
|
data/lib/oauth/client/helper.rb
CHANGED
@@ -27,7 +27,7 @@ module OAuth::Client
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def oauth_parameters
|
30
|
-
{
|
30
|
+
out = {
|
31
31
|
'oauth_body_hash' => options[:body_hash],
|
32
32
|
'oauth_callback' => options[:oauth_callback],
|
33
33
|
'oauth_consumer_key' => options[:consumer].key,
|
@@ -38,7 +38,13 @@ module OAuth::Client
|
|
38
38
|
'oauth_verifier' => options[:oauth_verifier],
|
39
39
|
'oauth_version' => (options[:oauth_version] || '1.0'),
|
40
40
|
'oauth_session_handle' => options[:oauth_session_handle]
|
41
|
-
}
|
41
|
+
}
|
42
|
+
allowed_empty_params = options[:allow_empty_params]
|
43
|
+
if allowed_empty_params != true && !allowed_empty_params.kind_of?(Array)
|
44
|
+
allowed_empty_params = allowed_empty_params == false ? [] : [allowed_empty_params]
|
45
|
+
end
|
46
|
+
out.select! { |k,v| v.to_s != '' || allowed_empty_params == true || allowed_empty_params.include?(k) }
|
47
|
+
out
|
42
48
|
end
|
43
49
|
|
44
50
|
def signature(extra_options = {})
|
data/lib/oauth/consumer.rb
CHANGED
@@ -8,11 +8,21 @@ require 'cgi'
|
|
8
8
|
module OAuth
|
9
9
|
class Consumer
|
10
10
|
# determine the certificate authority path to verify SSL certs
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
if ENV['SSL_CERT_FILE']
|
12
|
+
if File.exist?(ENV['SSL_CERT_FILE'])
|
13
|
+
CA_FILE = ENV['SSL_CERT_FILE']
|
14
|
+
else
|
15
|
+
raise "The SSL CERT provided does not exist."
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if !defined?(CA_FILE)
|
20
|
+
CA_FILES = %W(/etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt /usr/share/curl/curl-ca-bundle.crt)
|
21
|
+
CA_FILES.each do |ca_file|
|
22
|
+
if File.exist?(ca_file)
|
23
|
+
CA_FILE = ca_file
|
24
|
+
break
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
CA_FILE = nil unless defined?(CA_FILE)
|
@@ -23,6 +33,7 @@ module OAuth
|
|
23
33
|
|
24
34
|
# default paths on site. These are the same as the defaults set up by the generators
|
25
35
|
:request_token_path => '/oauth/request_token',
|
36
|
+
:authenticate_path => '/oauth/authenticate',
|
26
37
|
:authorize_path => '/oauth/authorize',
|
27
38
|
:access_token_path => '/oauth/access_token',
|
28
39
|
|
@@ -230,7 +241,14 @@ module OAuth
|
|
230
241
|
when (300..399)
|
231
242
|
# this is a redirect
|
232
243
|
uri = URI.parse(response['location'])
|
233
|
-
|
244
|
+
our_uri = URI.parse(site)
|
245
|
+
|
246
|
+
if uri.path == path && our_uri.host != uri.host
|
247
|
+
options[:site] = "#{uri.scheme}://#{uri.host}"
|
248
|
+
@http = create_http
|
249
|
+
end
|
250
|
+
|
251
|
+
response.error! if uri.path == path && our_uri.host == uri.host # careful of those infinite redirects
|
234
252
|
self.token_request(http_method, uri.path, token, request_options, arguments)
|
235
253
|
when (400..499)
|
236
254
|
raise OAuth::Unauthorized, response
|
@@ -266,6 +284,10 @@ module OAuth
|
|
266
284
|
@options[:request_token_path]
|
267
285
|
end
|
268
286
|
|
287
|
+
def authenticate_path
|
288
|
+
@options[:authenticate_path]
|
289
|
+
end
|
290
|
+
|
269
291
|
def authorize_path
|
270
292
|
@options[:authorize_path]
|
271
293
|
end
|
@@ -283,6 +305,14 @@ module OAuth
|
|
283
305
|
@options.has_key?(:request_token_url)
|
284
306
|
end
|
285
307
|
|
308
|
+
def authenticate_url
|
309
|
+
@options[:authenticate_url] || site + authenticate_path
|
310
|
+
end
|
311
|
+
|
312
|
+
def authenticate_url?
|
313
|
+
@options.has_key?(:authenticate_url)
|
314
|
+
end
|
315
|
+
|
286
316
|
def authorize_url
|
287
317
|
@options[:authorize_url] || site + authorize_path
|
288
318
|
end
|
@@ -330,12 +360,15 @@ module OAuth
|
|
330
360
|
|
331
361
|
http_object.use_ssl = (our_uri.scheme == 'https')
|
332
362
|
|
333
|
-
if @options[:
|
334
|
-
http_object.
|
363
|
+
if @options[:no_verify]
|
364
|
+
http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
365
|
+
else
|
366
|
+
ca_file = @options[:ca_file] || CA_FILE
|
367
|
+
if ca_file
|
368
|
+
http_object.ca_file = ca_file
|
369
|
+
end
|
335
370
|
http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
336
371
|
http_object.verify_depth = 5
|
337
|
-
else
|
338
|
-
http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
339
372
|
end
|
340
373
|
|
341
374
|
http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 30
|
@@ -8,7 +8,14 @@ module OAuth
|
|
8
8
|
return nil if self.token.nil?
|
9
9
|
|
10
10
|
params = (params || {}).merge(:oauth_token => self.token)
|
11
|
-
|
11
|
+
build_url(consumer.authorize_url, params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def authenticate_url(params = nil)
|
15
|
+
return nil if self.token.nil?
|
16
|
+
|
17
|
+
params = (params || {}).merge(:oauth_token => self.token)
|
18
|
+
build_url(consumer.authenticate_url, params)
|
12
19
|
end
|
13
20
|
|
14
21
|
def callback_confirmed?
|
@@ -23,8 +30,8 @@ module OAuth
|
|
23
30
|
|
24
31
|
protected
|
25
32
|
|
26
|
-
# construct an authorization url
|
27
|
-
def
|
33
|
+
# construct an authorization or authentication url
|
34
|
+
def build_url(base_url, params)
|
28
35
|
uri = URI.parse(base_url.to_s)
|
29
36
|
queries = {}
|
30
37
|
queries = Hash[URI.decode_www_form(uri.query)] if uri.query
|
data/lib/oauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -12,10 +12,10 @@ authors:
|
|
12
12
|
- Seth Fitzsimmons
|
13
13
|
- Matt Sanford
|
14
14
|
- Aaron Quint
|
15
|
-
autorequire:
|
15
|
+
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date:
|
18
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|
@@ -122,6 +122,9 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.9.12
|
125
|
+
- - "<="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 1.1.0
|
125
128
|
type: :development
|
126
129
|
prerelease: false
|
127
130
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -129,6 +132,9 @@ dependencies:
|
|
129
132
|
- - ">="
|
130
133
|
- !ruby/object:Gem::Version
|
131
134
|
version: 0.9.12
|
135
|
+
- - "<="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 1.1.0
|
132
138
|
- !ruby/object:Gem::Dependency
|
133
139
|
name: typhoeus
|
134
140
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,7 +233,7 @@ dependencies:
|
|
227
233
|
- - ">="
|
228
234
|
- !ruby/object:Gem::Version
|
229
235
|
version: '0'
|
230
|
-
description:
|
236
|
+
description:
|
231
237
|
email: oauth-ruby@googlegroupspec.com
|
232
238
|
executables:
|
233
239
|
- oauth
|
@@ -287,11 +293,11 @@ files:
|
|
287
293
|
- lib/oauth/tokens/server_token.rb
|
288
294
|
- lib/oauth/tokens/token.rb
|
289
295
|
- lib/oauth/version.rb
|
290
|
-
homepage:
|
296
|
+
homepage:
|
291
297
|
licenses:
|
292
298
|
- MIT
|
293
299
|
metadata: {}
|
294
|
-
post_install_message:
|
300
|
+
post_install_message:
|
295
301
|
rdoc_options: []
|
296
302
|
require_paths:
|
297
303
|
- lib
|
@@ -306,9 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
312
|
- !ruby/object:Gem::Version
|
307
313
|
version: '0'
|
308
314
|
requirements: []
|
309
|
-
|
310
|
-
|
311
|
-
signing_key:
|
315
|
+
rubygems_version: 3.0.8
|
316
|
+
signing_key:
|
312
317
|
specification_version: 4
|
313
318
|
summary: OAuth Core Ruby implementation
|
314
319
|
test_files: []
|