oauth 0.5.4 → 0.5.6
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.
- checksums.yaml +5 -5
- data/README.rdoc +11 -9
- data/lib/oauth.rb +1 -0
- data/lib/oauth/client/helper.rb +8 -2
- data/lib/oauth/consumer.rb +44 -11
- data/lib/oauth/request_proxy/action_controller_request.rb +5 -1
- data/lib/oauth/signature/hmac/sha256.rb +17 -0
- data/lib/oauth/tokens/request_token.rb +10 -3
- data/lib/oauth/version.rb +1 -1
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9bd785e08f2a318da373f07b79fe6583ed3e8c26bcc92c5e1513ee615ea0f037
|
4
|
+
data.tar.gz: 3e9f81feb37166f4fec398d20e8b4de882b6e1e2304f893c033b920ab737616a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc060045ecb7ca1c47263f4bab7fde62c3a173ccf7ea6e1dacc5ac4e814ecea88e4b2f594f6bd2a7d80f9393e1295b1a5cbc85f3eb74c35cbb348da6f32cfe6
|
7
|
+
data.tar.gz: c96c9abd68f71cca8d33db21e3d68f1c7fe98898dba924fd440bf882280d99d39beb7a0751be913bb0f18872875ca8098792733f1717ff8d127156a99a69f039
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== Status
|
4
4
|
|
5
|
-
{<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.
|
5
|
+
{<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.com/github/oauth-xx/oauth-ruby]
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -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.rb
CHANGED
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,15 +360,18 @@ 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
|
-
http_object.read_timeout = http_object.open_timeout = @options[:timeout] ||
|
374
|
+
http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 60
|
342
375
|
http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]
|
343
376
|
http_object.ssl_version = @options[:ssl_version] if @options[:ssl_version]
|
344
377
|
http_object.set_debug_output(debug_output) if debug_output
|
@@ -60,7 +60,7 @@ module OAuth::RequestProxy
|
|
60
60
|
params << header_params.to_query
|
61
61
|
params << request.query_string unless query_string_blank?
|
62
62
|
|
63
|
-
if
|
63
|
+
if raw_post_signature?
|
64
64
|
params << request.raw_post
|
65
65
|
end
|
66
66
|
end
|
@@ -72,6 +72,10 @@ module OAuth::RequestProxy
|
|
72
72
|
reject { |kv| kv[0] == 'oauth_signature'}
|
73
73
|
end
|
74
74
|
|
75
|
+
def raw_post_signature?
|
76
|
+
(request.post? || request.put?) && request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
|
77
|
+
end
|
78
|
+
|
75
79
|
protected
|
76
80
|
|
77
81
|
def query_params
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'oauth/signature/base'
|
2
|
+
|
3
|
+
module OAuth::Signature::HMAC
|
4
|
+
class SHA256 < OAuth::Signature::Base
|
5
|
+
implements 'hmac-sha256'
|
6
|
+
|
7
|
+
def body_hash
|
8
|
+
Base64.encode64(OpenSSL::Digest::SHA256.digest(request.body || '')).chomp.gsub(/\n/,'')
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def digest
|
14
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), secret, signature_base_string)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date:
|
18
|
+
date: 2021-04-02 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
|
@@ -278,6 +284,7 @@ files:
|
|
278
284
|
- lib/oauth/signature.rb
|
279
285
|
- lib/oauth/signature/base.rb
|
280
286
|
- lib/oauth/signature/hmac/sha1.rb
|
287
|
+
- lib/oauth/signature/hmac/sha256.rb
|
281
288
|
- lib/oauth/signature/plaintext.rb
|
282
289
|
- lib/oauth/signature/rsa/sha1.rb
|
283
290
|
- lib/oauth/token.rb
|
@@ -287,10 +294,15 @@ files:
|
|
287
294
|
- lib/oauth/tokens/server_token.rb
|
288
295
|
- lib/oauth/tokens/token.rb
|
289
296
|
- lib/oauth/version.rb
|
290
|
-
homepage:
|
297
|
+
homepage: https://github.com/oauth-xx/oauth-ruby
|
291
298
|
licenses:
|
292
299
|
- MIT
|
293
|
-
metadata:
|
300
|
+
metadata:
|
301
|
+
bug_tracker_uri: https://github.com/oauth-xx/oauth-ruby/issues
|
302
|
+
changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/master/HISTORY
|
303
|
+
documentation_uri: https://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
|
304
|
+
homepage_uri: https://github.com/oauth-xx/oauth-ruby
|
305
|
+
source_code_uri: https://github.com/oauth-xx/oauth-ruby
|
294
306
|
post_install_message:
|
295
307
|
rdoc_options: []
|
296
308
|
require_paths:
|
@@ -306,8 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
318
|
- !ruby/object:Gem::Version
|
307
319
|
version: '0'
|
308
320
|
requirements: []
|
309
|
-
|
310
|
-
rubygems_version: 2.2.2
|
321
|
+
rubygems_version: 3.0.3
|
311
322
|
signing_key:
|
312
323
|
specification_version: 4
|
313
324
|
summary: OAuth Core Ruby implementation
|