oauth 0.4.7 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oauth might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.rdoc +8 -8
- data/lib/oauth.rb +1 -3
- data/lib/oauth/cli.rb +3 -3
- data/lib/oauth/client/helper.rb +4 -0
- data/lib/oauth/client/net_http.rb +9 -7
- data/lib/oauth/consumer.rb +9 -5
- data/lib/oauth/helper.rb +3 -3
- data/lib/oauth/request_proxy/action_controller_request.rb +26 -2
- data/lib/oauth/request_proxy/base.rb +1 -1
- data/lib/oauth/request_proxy/net_http.rb +1 -1
- data/lib/oauth/request_proxy/rest_client_request.rb +62 -0
- data/lib/oauth/request_proxy/typhoeus_request.rb +4 -3
- data/lib/oauth/signature/base.rb +9 -23
- data/lib/oauth/signature/hmac/sha1.rb +12 -4
- data/lib/oauth/signature/plaintext.rb +6 -0
- data/lib/oauth/signature/rsa/sha1.rb +7 -3
- data/lib/oauth/tokens/access_token.rb +12 -0
- data/lib/oauth/tokens/request_token.rb +5 -0
- data/lib/oauth/tokens/token.rb +1 -1
- data/lib/oauth/version.rb +3 -0
- data/test/cases/oauth_case.rb +2 -2
- data/test/integration/consumer_test.rb +13 -13
- data/test/test_access_token.rb +2 -2
- data/test/test_action_controller_request_proxy.rb +29 -5
- data/test/test_consumer.rb +9 -3
- data/test/test_curb_request_proxy.rb +1 -1
- data/test/test_em_http_client.rb +1 -1
- data/test/test_em_http_request_proxy.rb +1 -1
- data/test/test_helper.rb +8 -3
- data/test/test_hmac_sha1.rb +1 -1
- data/test/test_net_http_client.rb +7 -1
- data/test/test_net_http_request_proxy.rb +1 -1
- data/test/test_oauth_helper.rb +5 -5
- data/test/test_rack_request_proxy.rb +1 -1
- data/test/test_request_token.rb +9 -4
- data/test/test_rest_client_request_proxy.rb +81 -0
- data/test/test_rsa_sha1.rb +1 -1
- data/test/test_server.rb +7 -6
- data/test/test_signature.rb +6 -13
- data/test/test_signature_base.rb +6 -6
- data/test/test_signature_hmac_sha1.rb +40 -0
- data/test/test_signature_plain_text.rb +1 -1
- data/test/test_token.rb +1 -1
- data/test/test_typhoeus_request_proxy.rb +24 -3
- metadata +126 -74
- data/.gemtest +0 -0
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -47
- data/HISTORY +0 -173
- data/Rakefile +0 -37
- data/examples/yql.rb +0 -44
- data/lib/digest/hmac.rb +0 -104
- data/lib/oauth/signature/hmac/base.rb +0 -15
- data/lib/oauth/signature/hmac/md5.rb +0 -8
- data/lib/oauth/signature/hmac/rmd160.rb +0 -8
- data/lib/oauth/signature/hmac/sha2.rb +0 -8
- data/lib/oauth/signature/md5.rb +0 -13
- data/lib/oauth/signature/sha1.rb +0 -13
- data/oauth.gemspec +0 -148
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/keys/rsa.cert +0 -11
- data/test/keys/rsa.pem +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b45dc41aae4a7483d4dc3f37231ed79084a7c8e
|
4
|
+
data.tar.gz: c82a432eb7f1a7ab2cb704eedd1ae9da15daed2c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b3a8ebb69c99d98762a66ddaec9074ee6161824405f04dab2d057e8059fa6cb298985c951479980c41800508a11edbc439a38602e39384add3c2a9424be8975
|
7
|
+
data.tar.gz: 65f7255a19a1def380575faa1a97d95ec78821fcf687ff8f914a10d367dcc6e05d1681e4a7b9106973e5a50618457e35d8c1b07adbf21919e668345ca18143ab
|
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ See the OAuth specs http://oauth.net/core/1.0/
|
|
10
10
|
|
11
11
|
sudo gem install oauth
|
12
12
|
|
13
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
|
13
|
+
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
|
14
14
|
|
15
15
|
== The basics
|
16
16
|
|
@@ -44,9 +44,9 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
|
|
44
44
|
require 'oauth/request_proxy/typhoeus_request'
|
45
45
|
oauth_params = {:consumer => oauth_consumer, :token => access_token}
|
46
46
|
hydra = Typhoeus::Hydra.new
|
47
|
-
req = Typhoeus::Request.new(uri, options)
|
47
|
+
req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
|
48
48
|
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
|
49
|
-
req.headers.merge!({"Authorization" => oauth_helper.header}) # Signs the request
|
49
|
+
req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
|
50
50
|
hydra.queue(req)
|
51
51
|
hydra.run
|
52
52
|
@response = req.response
|
@@ -54,22 +54,22 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
|
|
54
54
|
|
55
55
|
== More Information
|
56
56
|
|
57
|
-
* RDoc: http://rdoc.info/
|
57
|
+
* RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
|
58
58
|
* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby
|
59
59
|
|
60
60
|
== How to submit patches
|
61
61
|
|
62
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
|
62
|
+
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
|
63
63
|
|
64
64
|
To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
|
65
65
|
|
66
66
|
== License
|
67
67
|
|
68
|
-
This code is free to use under the terms of the MIT license.
|
68
|
+
This code is free to use under the terms of the MIT license.
|
69
69
|
|
70
70
|
== Contact
|
71
71
|
|
72
|
-
OAuth Ruby has been created and maintained by a large number of talented individuals.
|
72
|
+
OAuth Ruby has been created and maintained by a large number of talented individuals.
|
73
73
|
The current maintainer is Aaron Quint (quirkey).
|
74
74
|
|
75
|
-
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
|
75
|
+
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
|
data/lib/oauth.rb
CHANGED
data/lib/oauth/cli.rb
CHANGED
@@ -57,7 +57,7 @@ module OAuth
|
|
57
57
|
oauth_verifier = nil
|
58
58
|
|
59
59
|
# get a request token
|
60
|
-
request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { "scope" => options[:scope] })
|
60
|
+
request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, options[:scope] ? { "scope" => options[:scope] } : {})
|
61
61
|
|
62
62
|
if request_token.callback_confirmed?
|
63
63
|
stdout.puts "Server appears to support OAuth 1.0a; enabling support."
|
@@ -107,7 +107,7 @@ module OAuth
|
|
107
107
|
uri.query = [uri.query, *params].reject { |x| x.nil? } * "&"
|
108
108
|
p uri.to_s
|
109
109
|
|
110
|
-
response = access_token.request(options[:method].downcase.to_sym, uri.to_s)
|
110
|
+
response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
|
111
111
|
puts "#{response.code} #{response.message}"
|
112
112
|
puts response.body
|
113
113
|
when "sign"
|
@@ -268,7 +268,7 @@ module OAuth
|
|
268
268
|
options[:uri] = v
|
269
269
|
end
|
270
270
|
|
271
|
-
opts.on(
|
271
|
+
opts.on("--version [VERSION]", "Specifies the OAuth version to use.") do |v|
|
272
272
|
if v
|
273
273
|
options[:oauth_version] = v
|
274
274
|
else
|
data/lib/oauth/client/helper.rb
CHANGED
@@ -56,6 +56,10 @@ module OAuth::Client
|
|
56
56
|
:parameters => oauth_parameters}.merge(extra_options) )
|
57
57
|
end
|
58
58
|
|
59
|
+
def token_request?
|
60
|
+
@options[:token_request].eql?(true)
|
61
|
+
end
|
62
|
+
|
59
63
|
def hash_body
|
60
64
|
@options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters)
|
61
65
|
end
|
@@ -21,7 +21,8 @@ class Net::HTTPGenericRequest
|
|
21
21
|
# This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
|
22
22
|
#
|
23
23
|
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1],
|
24
|
-
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html
|
24
|
+
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
|
25
|
+
# http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
|
25
26
|
def oauth!(http, consumer = nil, token = nil, options = {})
|
26
27
|
helper_options = oauth_helper_options(http, consumer, token, options)
|
27
28
|
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
|
@@ -42,13 +43,14 @@ class Net::HTTPGenericRequest
|
|
42
43
|
# * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
|
43
44
|
# +signature_method+, +nonce+, +timestamp+)
|
44
45
|
#
|
45
|
-
# See Also: {OAuth core spec version 1.0, section
|
46
|
-
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html
|
46
|
+
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1],
|
47
|
+
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
|
48
|
+
# http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
|
47
49
|
def signature_base_string(http, consumer = nil, token = nil, options = {})
|
48
50
|
helper_options = oauth_helper_options(http, consumer, token, options)
|
49
|
-
oauth_helper = OAuth::Client::Helper.new(self, helper_options)
|
50
|
-
oauth_helper.hash_body if oauth_body_hash_required?
|
51
|
-
oauth_helper.signature_base_string
|
51
|
+
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
|
52
|
+
@oauth_helper.hash_body if oauth_body_hash_required?
|
53
|
+
@oauth_helper.signature_base_string
|
52
54
|
end
|
53
55
|
|
54
56
|
private
|
@@ -84,7 +86,7 @@ private
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def oauth_body_hash_required?
|
87
|
-
request_body_permitted? && !content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
|
89
|
+
!@oauth_helper.token_request? && request_body_permitted? && !content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
|
88
90
|
end
|
89
91
|
|
90
92
|
def set_oauth_header
|
data/lib/oauth/consumer.rb
CHANGED
@@ -8,9 +8,9 @@ require 'cgi'
|
|
8
8
|
module OAuth
|
9
9
|
class Consumer
|
10
10
|
# determine the certificate authority path to verify SSL certs
|
11
|
-
CA_FILES = %
|
11
|
+
CA_FILES = %W(#{ENV['SSL_CERT_FILE']} /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt /usr/share/curl/curl-ca-bundle.crt)
|
12
12
|
CA_FILES.each do |ca_file|
|
13
|
-
if File.
|
13
|
+
if File.exist?(ca_file)
|
14
14
|
CA_FILE = ca_file
|
15
15
|
break
|
16
16
|
end
|
@@ -191,6 +191,7 @@ module OAuth
|
|
191
191
|
|
192
192
|
# Creates a request and parses the result as url_encoded. This is used internally for the RequestToken and AccessToken requests.
|
193
193
|
def token_request(http_method, path, token = nil, request_options = {}, *arguments)
|
194
|
+
request_options[:token_request] ||= true
|
194
195
|
response = request(http_method, path, token, request_options, *arguments)
|
195
196
|
case response.code.to_i
|
196
197
|
|
@@ -234,8 +235,8 @@ module OAuth
|
|
234
235
|
end
|
235
236
|
|
236
237
|
def request_endpoint
|
237
|
-
|
238
|
-
|
238
|
+
return nil if @options[:request_endpoint].nil?
|
239
|
+
@options[:request_endpoint].to_s
|
239
240
|
end
|
240
241
|
|
241
242
|
def scheme
|
@@ -328,7 +329,7 @@ module OAuth
|
|
328
329
|
def create_http_request(http_method, path, *arguments)
|
329
330
|
http_method = http_method.to_sym
|
330
331
|
|
331
|
-
if [:post, :put].include?(http_method)
|
332
|
+
if [:post, :put, :patch].include?(http_method)
|
332
333
|
data = arguments.shift
|
333
334
|
end
|
334
335
|
|
@@ -345,6 +346,9 @@ module OAuth
|
|
345
346
|
when :put
|
346
347
|
request = Net::HTTP::Put.new(path,headers)
|
347
348
|
request["Content-Length"] = '0' # Default to 0
|
349
|
+
when :patch
|
350
|
+
request = Net::HTTP::Patch.new(path,headers)
|
351
|
+
request["Content-Length"] = '0' # Default to 0
|
348
352
|
when :get
|
349
353
|
request = Net::HTTP::Get.new(path,headers)
|
350
354
|
when :delete
|
data/lib/oauth/helper.rb
CHANGED
@@ -9,9 +9,9 @@ module OAuth
|
|
9
9
|
#
|
10
10
|
# See Also: {OAuth core spec version 1.0, section 5.1}[http://oauth.net/core/1.0#rfc.section.5.1]
|
11
11
|
def escape(value)
|
12
|
-
URI::escape(value.to_s, OAuth::RESERVED_CHARACTERS)
|
12
|
+
URI::escape(value.to_s.to_str, OAuth::RESERVED_CHARACTERS)
|
13
13
|
rescue ArgumentError
|
14
|
-
URI::escape(value.to_s.force_encoding(Encoding::UTF_8), OAuth::RESERVED_CHARACTERS)
|
14
|
+
URI::escape(value.to_s.to_str.force_encoding(Encoding::UTF_8), OAuth::RESERVED_CHARACTERS)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
|
@@ -49,7 +49,7 @@ module OAuth
|
|
49
49
|
end
|
50
50
|
end * "&"
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
#Returns a string representation of the Hash like in URL query string
|
54
54
|
# build_nested_query({:level_1 => {:level_2 => ['value_1','value_2']}}, 'prefix'))
|
55
55
|
# #=> ["prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_1", "prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_2"]
|
@@ -1,11 +1,35 @@
|
|
1
1
|
require 'active_support'
|
2
|
+
require "active_support/version"
|
2
3
|
require 'action_controller'
|
3
|
-
require 'action_controller/request'
|
4
4
|
require 'uri'
|
5
5
|
|
6
|
+
if
|
7
|
+
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("3")
|
8
|
+
then # rails 2.x
|
9
|
+
require 'action_controller/request'
|
10
|
+
unless ActionController::Request::HTTP_METHODS.include?("patch")
|
11
|
+
ActionController::Request::HTTP_METHODS << "patch"
|
12
|
+
ActionController::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
|
13
|
+
ActionController::Request::HTTP_METHOD_LOOKUP["patch"] = :patch
|
14
|
+
end
|
15
|
+
|
16
|
+
elsif
|
17
|
+
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("4")
|
18
|
+
then # rails 3.x
|
19
|
+
require 'action_dispatch/http/request'
|
20
|
+
unless ActionDispatch::Request::HTTP_METHODS.include?("patch")
|
21
|
+
ActionDispatch::Request::HTTP_METHODS << "patch"
|
22
|
+
ActionDispatch::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
|
23
|
+
ActionDispatch::Request::HTTP_METHOD_LOOKUP["patch"] = :patch
|
24
|
+
end
|
25
|
+
|
26
|
+
else # rails 4.x - already has patch
|
27
|
+
require 'action_dispatch/http/request'
|
28
|
+
end
|
29
|
+
|
6
30
|
module OAuth::RequestProxy
|
7
31
|
class ActionControllerRequest < OAuth::RequestProxy::Base
|
8
|
-
proxies(defined?(
|
32
|
+
proxies(defined?(ActionDispatch::AbstractRequest) ? ActionDispatch::AbstractRequest : ActionDispatch::Request)
|
9
33
|
|
10
34
|
def method
|
11
35
|
request.method.to_s.upcase
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'oauth/request_proxy/base'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'uri'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module OAuth::RequestProxy::RestClient
|
7
|
+
class Request < OAuth::RequestProxy::Base
|
8
|
+
proxies RestClient::Request
|
9
|
+
|
10
|
+
def method
|
11
|
+
request.method.to_s.upcase
|
12
|
+
end
|
13
|
+
|
14
|
+
def uri
|
15
|
+
request.url
|
16
|
+
end
|
17
|
+
|
18
|
+
def parameters
|
19
|
+
if options[:clobber_request]
|
20
|
+
options[:parameters] || {}
|
21
|
+
else
|
22
|
+
post_parameters.merge(query_params).merge(options[:parameters] || {})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def query_params
|
29
|
+
query = URI.parse(request.url).query
|
30
|
+
query ? CGI.parse(query) : {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def request_params
|
34
|
+
end
|
35
|
+
|
36
|
+
def post_parameters
|
37
|
+
# Post params are only used if posting form data
|
38
|
+
if method == 'POST' || method == 'PUT'
|
39
|
+
OAuth::Helper.stringify_keys(query_string_to_hash(request.payload.to_s) || {})
|
40
|
+
else
|
41
|
+
{}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def query_string_to_hash(query)
|
48
|
+
keyvals = query.split('&').inject({}) do |result, q|
|
49
|
+
k,v = q.split('=')
|
50
|
+
if !v.nil?
|
51
|
+
result.merge({k => v})
|
52
|
+
elsif !result.key?(k)
|
53
|
+
result.merge({k => true})
|
54
|
+
else
|
55
|
+
result
|
56
|
+
end
|
57
|
+
end
|
58
|
+
keyvals
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -11,7 +11,7 @@ module OAuth::RequestProxy::Typhoeus
|
|
11
11
|
# oauth_params = {:consumer => oauth_consumer, :token => access_token}
|
12
12
|
# req = Typhoeus::Request.new(uri, options)
|
13
13
|
# oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
|
14
|
-
# req.headers.merge!({"Authorization" => oauth_helper.header})
|
14
|
+
# req.options[:headers].merge!({"Authorization" => oauth_helper.header})
|
15
15
|
# hydra = Typhoeus::Hydra.new()
|
16
16
|
# hydra.queue(req)
|
17
17
|
# hydra.run
|
@@ -19,7 +19,8 @@ module OAuth::RequestProxy::Typhoeus
|
|
19
19
|
proxies Typhoeus::Request
|
20
20
|
|
21
21
|
def method
|
22
|
-
request.method.to_s.upcase
|
22
|
+
request_method = request.options[:method].to_s.upcase
|
23
|
+
request_method.empty? ? 'GET' : request_method
|
23
24
|
end
|
24
25
|
|
25
26
|
def uri
|
@@ -44,7 +45,7 @@ module OAuth::RequestProxy::Typhoeus
|
|
44
45
|
def post_parameters
|
45
46
|
# Post params are only used if posting form data
|
46
47
|
if method == 'POST'
|
47
|
-
OAuth::Helper.stringify_keys(request.params || {})
|
48
|
+
OAuth::Helper.stringify_keys(request.options[:params] || {})
|
48
49
|
else
|
49
50
|
{}
|
50
51
|
end
|
data/lib/oauth/signature/base.rb
CHANGED
@@ -16,21 +16,6 @@ module OAuth::Signature
|
|
16
16
|
OAuth::Signature.available_methods[@implements] = self
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.digest_class(digest_class = nil)
|
20
|
-
return @digest_class if digest_class.nil?
|
21
|
-
@digest_class = digest_class
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.digest_klass(digest_klass = nil)
|
25
|
-
return @digest_klass if digest_klass.nil?
|
26
|
-
@digest_klass = digest_klass
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.hash_class(hash_class = nil)
|
30
|
-
return @hash_class if hash_class.nil?
|
31
|
-
@hash_class = hash_class
|
32
|
-
end
|
33
|
-
|
34
19
|
def initialize(request, options = {}, &block)
|
35
20
|
raise TypeError unless request.kind_of?(OAuth::RequestProxy::Base)
|
36
21
|
@request = request
|
@@ -66,7 +51,7 @@ module OAuth::Signature
|
|
66
51
|
end
|
67
52
|
|
68
53
|
def ==(cmp_signature)
|
69
|
-
|
54
|
+
signature == cmp_signature
|
70
55
|
end
|
71
56
|
|
72
57
|
def verify
|
@@ -78,14 +63,10 @@ module OAuth::Signature
|
|
78
63
|
end
|
79
64
|
|
80
65
|
def body_hash
|
81
|
-
|
82
|
-
Base64.encode64(self.class.hash_class.digest(request.body || '')).chomp.gsub(/\n/,'')
|
83
|
-
else
|
84
|
-
nil # no body hash algorithm defined, so don't generate one
|
85
|
-
end
|
66
|
+
raise_instantiation_error
|
86
67
|
end
|
87
68
|
|
88
|
-
|
69
|
+
private
|
89
70
|
|
90
71
|
def token
|
91
72
|
request.token
|
@@ -104,7 +85,12 @@ module OAuth::Signature
|
|
104
85
|
end
|
105
86
|
|
106
87
|
def digest
|
107
|
-
|
88
|
+
raise_instantiation_error
|
108
89
|
end
|
90
|
+
|
91
|
+
def raise_instantiation_error
|
92
|
+
raise NotImplementedError, "Cannot instantiate #{self.class.name} class directly."
|
93
|
+
end
|
94
|
+
|
109
95
|
end
|
110
96
|
end
|
@@ -1,9 +1,17 @@
|
|
1
|
-
require 'oauth/signature/
|
1
|
+
require 'oauth/signature/base'
|
2
2
|
|
3
3
|
module OAuth::Signature::HMAC
|
4
|
-
class SHA1 < Base
|
4
|
+
class SHA1 < OAuth::Signature::Base
|
5
5
|
implements 'hmac-sha1'
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
def body_hash
|
8
|
+
Base64.encode64(OpenSSL::Digest::SHA1.digest(request.body || '')).chomp.gsub(/\n/,'')
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def digest
|
14
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), secret, signature_base_string)
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|