oauth 0.5.7.pre.pre1 → 0.5.9
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 +4 -4
- data/CHANGELOG.md +54 -104
- data/CODE_OF_CONDUCT.md +0 -0
- data/CONTRIBUTING.md +23 -0
- data/LICENSE +0 -0
- data/README.md +50 -67
- data/SECURITY.md +16 -0
- data/TODO +0 -0
- data/lib/oauth/cli/authorize_command.rb +8 -10
- data/lib/oauth/cli/base_command.rb +8 -6
- data/lib/oauth/cli/help_command.rb +0 -0
- data/lib/oauth/cli/query_command.rb +3 -3
- data/lib/oauth/cli/sign_command.rb +12 -15
- data/lib/oauth/cli/version_command.rb +0 -0
- data/lib/oauth/cli.rb +2 -2
- data/lib/oauth/client/action_controller_request.rb +14 -15
- data/lib/oauth/client/em_http.rb +28 -28
- data/lib/oauth/client/helper.rb +14 -17
- data/lib/oauth/client/net_http.rb +27 -27
- data/lib/oauth/client.rb +0 -0
- data/lib/oauth/consumer.rb +52 -62
- data/lib/oauth/errors/error.rb +0 -0
- data/lib/oauth/errors/problem.rb +0 -0
- data/lib/oauth/errors/unauthorized.rb +0 -0
- data/lib/oauth/errors.rb +0 -0
- data/lib/oauth/helper.rb +7 -7
- data/lib/oauth/oauth.rb +4 -4
- data/lib/oauth/oauth_test_helper.rb +0 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +50 -51
- data/lib/oauth/request_proxy/action_dispatch_request.rb +7 -3
- data/lib/oauth/request_proxy/base.rb +134 -130
- data/lib/oauth/request_proxy/curb_request.rb +45 -39
- data/lib/oauth/request_proxy/em_http_request.rb +56 -52
- data/lib/oauth/request_proxy/jabber_request.rb +9 -6
- data/lib/oauth/request_proxy/mock_request.rb +3 -1
- data/lib/oauth/request_proxy/net_http.rb +59 -50
- data/lib/oauth/request_proxy/rack_request.rb +32 -28
- data/lib/oauth/request_proxy/rest_client_request.rb +48 -45
- data/lib/oauth/request_proxy/typhoeus_request.rb +45 -39
- data/lib/oauth/request_proxy.rb +3 -3
- data/lib/oauth/server.rb +8 -10
- data/lib/oauth/signature/base.rb +3 -4
- data/lib/oauth/signature/hmac/sha1.rb +1 -1
- data/lib/oauth/signature/hmac/sha256.rb +1 -1
- data/lib/oauth/signature/plaintext.rb +0 -0
- data/lib/oauth/signature/rsa/sha1.rb +3 -3
- data/lib/oauth/signature.rb +5 -5
- data/lib/oauth/token.rb +0 -0
- data/lib/oauth/tokens/access_token.rb +0 -0
- data/lib/oauth/tokens/consumer_token.rb +2 -2
- data/lib/oauth/tokens/request_token.rb +7 -8
- data/lib/oauth/tokens/server_token.rb +0 -1
- data/lib/oauth/tokens/token.rb +0 -0
- data/lib/oauth/version.rb +1 -1
- data/lib/oauth.rb +0 -0
- metadata +12 -163
data/SECURITY.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
| Version | Supported |
|
6
|
+
| ------- | ------------------ |
|
7
|
+
| 0.7.x | :white_check_mark: |
|
8
|
+
| 0.6.x | :white_check_mark: |
|
9
|
+
| 0.5.x | :white_check_mark: |
|
10
|
+
| <= 0.5 | :x: |
|
11
|
+
|
12
|
+
## Reporting a Vulnerability
|
13
|
+
|
14
|
+
Peter Boling is the primary maintainer of the this gem. Please find a way to [contact him directly][contact] to report the issue. Include as much relevant information as possible.
|
15
|
+
|
16
|
+
[contact]: https://railsbling.com/contact
|
data/TODO
CHANGED
File without changes
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class OAuth::CLI
|
2
2
|
class AuthorizeCommand < BaseCommand
|
3
|
-
|
4
3
|
def required_options
|
5
4
|
[:uri]
|
6
5
|
end
|
@@ -25,7 +24,7 @@ class OAuth::CLI
|
|
25
24
|
def get_request_token
|
26
25
|
consumer = get_consumer
|
27
26
|
scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
|
28
|
-
consumer.get_request_token({ :
|
27
|
+
consumer.get_request_token({ oauth_callback: options[:oauth_callback] }, scope_options)
|
29
28
|
rescue OAuth::Unauthorized => e
|
30
29
|
alert "A problem occurred while attempting to authorize:"
|
31
30
|
alert e
|
@@ -36,14 +35,13 @@ class OAuth::CLI
|
|
36
35
|
OAuth::Consumer.new \
|
37
36
|
options[:oauth_consumer_key],
|
38
37
|
options[:oauth_consumer_secret],
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
38
|
+
access_token_url: options[:access_token_url],
|
39
|
+
authorize_url: options[:authorize_url],
|
40
|
+
request_token_url: options[:request_token_url],
|
41
|
+
scheme: options[:scheme],
|
42
|
+
http_method: options[:method].to_s.downcase.to_sym
|
44
43
|
end
|
45
44
|
|
46
|
-
|
47
45
|
def ask_user_for_verifier
|
48
46
|
if options[:version] == "1.0a"
|
49
47
|
puts "Please enter the verification code provided by the SP (oauth_verifier):"
|
@@ -56,10 +54,10 @@ class OAuth::CLI
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def verbosely_get_access_token(request_token, oauth_verifier)
|
59
|
-
access_token = request_token.get_access_token(:
|
57
|
+
access_token = request_token.get_access_token(oauth_verifier: oauth_verifier)
|
60
58
|
|
61
59
|
puts "Response:"
|
62
|
-
access_token.params.each do |k,v|
|
60
|
+
access_token.params.each do |k, v|
|
63
61
|
puts " #{k}: #{v}" unless k.is_a?(Symbol)
|
64
62
|
end
|
65
63
|
rescue OAuth::Unauthorized => e
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class OAuth::CLI
|
2
2
|
class BaseCommand
|
3
3
|
def initialize(stdout, stdin, stderr, arguments)
|
4
|
-
@stdout
|
4
|
+
@stdout = stdout
|
5
|
+
@stdin = stdin
|
6
|
+
@stderr = stderr
|
5
7
|
|
6
8
|
@options = {}
|
7
9
|
option_parser.parse!(arguments)
|
@@ -38,11 +40,11 @@ class OAuth::CLI
|
|
38
40
|
options[:verbose]
|
39
41
|
end
|
40
42
|
|
41
|
-
def puts(string=nil)
|
43
|
+
def puts(string = nil)
|
42
44
|
@stdout.puts(string)
|
43
45
|
end
|
44
46
|
|
45
|
-
def alert(string=nil)
|
47
|
+
def alert(string = nil)
|
46
48
|
@stderr.puts(string)
|
47
49
|
end
|
48
50
|
|
@@ -50,8 +52,8 @@ class OAuth::CLI
|
|
50
52
|
@parameters ||= begin
|
51
53
|
escaped_pairs = options[:params].collect do |pair|
|
52
54
|
if pair =~ /:/
|
53
|
-
Hash[*pair.split(":", 2)].collect do |k,v|
|
54
|
-
[CGI.escape(k.strip), CGI.escape(v.strip)]
|
55
|
+
Hash[*pair.split(":", 2)].collect do |k, v|
|
56
|
+
[CGI.escape(k.strip), CGI.escape(v.strip)].join("=")
|
55
57
|
end
|
56
58
|
else
|
57
59
|
pair
|
@@ -68,7 +70,7 @@ class OAuth::CLI
|
|
68
70
|
"oauth_token" => options[:oauth_token],
|
69
71
|
"oauth_signature_method" => options[:oauth_signature_method],
|
70
72
|
"oauth_version" => options[:oauth_version]
|
71
|
-
}.reject { |_k,v| v.nil? || v == "" }.merge(cli_params)
|
73
|
+
}.reject { |_k, v| v.nil? || v == "" }.merge(cli_params)
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
File without changes
|
@@ -3,7 +3,7 @@ class OAuth::CLI
|
|
3
3
|
extend OAuth::Helper
|
4
4
|
|
5
5
|
def required_options
|
6
|
-
[
|
6
|
+
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
7
7
|
end
|
8
8
|
|
9
9
|
def _run
|
@@ -13,8 +13,8 @@ class OAuth::CLI
|
|
13
13
|
|
14
14
|
# append params to the URL
|
15
15
|
uri = URI.parse(options[:uri])
|
16
|
-
params = parameters.map { |k,v| Array(v).map { |v2| "#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}" } * "&" }
|
17
|
-
uri.query = [uri.query, *params].reject
|
16
|
+
params = parameters.map { |k, v| Array(v).map { |v2| "#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}" } * "&" }
|
17
|
+
uri.query = [uri.query, *params].reject(&:nil?) * "&"
|
18
18
|
puts uri.to_s
|
19
19
|
|
20
20
|
response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
|
@@ -1,23 +1,20 @@
|
|
1
1
|
class OAuth::CLI
|
2
2
|
class SignCommand < BaseCommand
|
3
|
-
|
4
3
|
def required_options
|
5
|
-
[
|
4
|
+
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
6
5
|
end
|
7
6
|
|
8
7
|
def _run
|
9
8
|
request = OAuth::RequestProxy.proxy \
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
"method" => options[:method],
|
10
|
+
"uri" => options[:uri],
|
11
|
+
"parameters" => parameters
|
13
12
|
|
14
|
-
if verbose?
|
15
|
-
puts_verbose_parameters(request)
|
16
|
-
end
|
13
|
+
puts_verbose_parameters(request) if verbose?
|
17
14
|
|
18
15
|
request.sign! \
|
19
|
-
:
|
20
|
-
:
|
16
|
+
consumer_secret: options[:oauth_consumer_secret],
|
17
|
+
token_secret: options[:oauth_token_secret]
|
21
18
|
|
22
19
|
if verbose?
|
23
20
|
puts_verbose_request(request)
|
@@ -28,15 +25,15 @@ class OAuth::CLI
|
|
28
25
|
|
29
26
|
def puts_verbose_parameters(request)
|
30
27
|
puts "OAuth parameters:"
|
31
|
-
request.oauth_parameters.each do |k,v|
|
32
|
-
puts " " + [k, v]
|
28
|
+
request.oauth_parameters.each do |k, v|
|
29
|
+
puts " " + [k, v].join(": ")
|
33
30
|
end
|
34
31
|
puts
|
35
32
|
|
36
33
|
if request.non_oauth_parameters.any?
|
37
34
|
puts "Parameters:"
|
38
|
-
request.non_oauth_parameters.each do |k,v|
|
39
|
-
puts " " + [k, v]
|
35
|
+
request.non_oauth_parameters.each do |k, v|
|
36
|
+
puts " " + [k, v].join(": ")
|
40
37
|
end
|
41
38
|
puts
|
42
39
|
end
|
@@ -58,7 +55,7 @@ class OAuth::CLI
|
|
58
55
|
else
|
59
56
|
puts "OAuth Request URI: #{request.signed_uri}"
|
60
57
|
puts "Request URI: #{request.signed_uri(false)}"
|
61
|
-
puts "Authorization header: #{request.oauth_header(:
|
58
|
+
puts "Authorization header: #{request.oauth_header(realm: options[:realm])}"
|
62
59
|
end
|
63
60
|
puts "Signature: #{request.oauth_signature}"
|
64
61
|
puts "Escaped signature: #{OAuth::Helper.escape(request.oauth_signature)}"
|
File without changes
|
data/lib/oauth/cli.rb
CHANGED
@@ -10,12 +10,12 @@ end
|
|
10
10
|
module ActionController
|
11
11
|
class Base
|
12
12
|
if defined? ActionDispatch
|
13
|
-
def process_with_new_base_test(request, response=nil)
|
13
|
+
def process_with_new_base_test(request, response = nil)
|
14
14
|
request.apply_oauth! if request.respond_to?(:apply_oauth!)
|
15
15
|
super(request, response)
|
16
16
|
end
|
17
17
|
else
|
18
|
-
def process_with_oauth(request, response=nil)
|
18
|
+
def process_with_oauth(request, response = nil)
|
19
19
|
request.apply_oauth! if request.respond_to?(:apply_oauth!)
|
20
20
|
process_without_oauth(request, response)
|
21
21
|
end
|
@@ -24,8 +24,8 @@ module ActionController
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class TestRequest
|
27
|
-
|
28
|
-
|
27
|
+
class << self
|
28
|
+
attr_writer :use_oauth
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.use_oauth?
|
@@ -33,21 +33,21 @@ module ActionController
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def configure_oauth(consumer = nil, token = nil, options = {})
|
36
|
-
@oauth_options = { :
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
36
|
+
@oauth_options = { consumer: consumer,
|
37
|
+
token: token,
|
38
|
+
scheme: "header",
|
39
|
+
signature_method: nil,
|
40
|
+
nonce: nil,
|
41
|
+
timestamp: nil }.merge(options)
|
42
42
|
end
|
43
43
|
|
44
44
|
def apply_oauth!
|
45
45
|
return unless ActionController::TestRequest.use_oauth? && @oauth_options
|
46
46
|
|
47
|
-
@oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:
|
47
|
+
@oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri)))
|
48
48
|
@oauth_helper.amend_user_agent_header(env)
|
49
49
|
|
50
|
-
|
50
|
+
send("set_oauth_#{@oauth_options[:scheme]}")
|
51
51
|
end
|
52
52
|
|
53
53
|
def set_oauth_header
|
@@ -56,10 +56,9 @@ module ActionController
|
|
56
56
|
|
57
57
|
def set_oauth_parameters
|
58
58
|
@query_parameters = @oauth_helper.parameters_with_oauth
|
59
|
-
@query_parameters.merge!(:
|
59
|
+
@query_parameters.merge!(oauth_signature: @oauth_helper.signature)
|
60
60
|
end
|
61
61
|
|
62
|
-
def set_oauth_query_string
|
63
|
-
end
|
62
|
+
def set_oauth_query_string; end
|
64
63
|
end
|
65
64
|
end
|
data/lib/oauth/client/em_http.rb
CHANGED
@@ -23,16 +23,16 @@ module EventMachine
|
|
23
23
|
#
|
24
24
|
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
|
25
25
|
def oauth!(http, consumer = nil, token = nil, options = {})
|
26
|
-
options = { :
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
26
|
+
options = { request_uri: normalized_oauth_uri(http),
|
27
|
+
consumer: consumer,
|
28
|
+
token: token,
|
29
|
+
scheme: "header",
|
30
|
+
signature_method: nil,
|
31
|
+
nonce: nil,
|
32
|
+
timestamp: nil }.merge(options)
|
33
33
|
|
34
34
|
@oauth_helper = OAuth::Client::Helper.new(self, options)
|
35
|
-
|
35
|
+
__send__(:"set_oauth_#{options[:scheme]}")
|
36
36
|
end
|
37
37
|
|
38
38
|
# Create a string suitable for signing for an HTTP request. This process involves parameter
|
@@ -49,13 +49,13 @@ module EventMachine
|
|
49
49
|
#
|
50
50
|
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
51
51
|
def signature_base_string(http, consumer = nil, token = nil, options = {})
|
52
|
-
options = { :
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
52
|
+
options = { request_uri: normalized_oauth_uri(http),
|
53
|
+
consumer: consumer,
|
54
|
+
token: token,
|
55
|
+
scheme: "header",
|
56
|
+
signature_method: nil,
|
57
|
+
nonce: nil,
|
58
|
+
timestamp: nil }.merge(options)
|
59
59
|
|
60
60
|
OAuth::Client::Helper.new(self, options).signature_base_string
|
61
61
|
end
|
@@ -77,13 +77,13 @@ module EventMachine
|
|
77
77
|
protected
|
78
78
|
|
79
79
|
def combine_query(path, query, uri_query)
|
80
|
-
combined_query = if query.
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
combined_query = if query.is_a?(Hash)
|
81
|
+
query.map { |k, v| encode_param(k, v) }.join("&")
|
82
|
+
else
|
83
|
+
query.to_s
|
84
84
|
end
|
85
|
-
|
86
|
-
combined_query = [combined_query, uri_query].reject
|
85
|
+
unless uri_query.to_s.empty?
|
86
|
+
combined_query = [combined_query, uri_query].reject(&:empty?).join("&")
|
87
87
|
end
|
88
88
|
combined_query.to_s.empty? ? path : "#{path}?#{combined_query}"
|
89
89
|
end
|
@@ -95,17 +95,17 @@ module EventMachine
|
|
95
95
|
uri.host = http.address
|
96
96
|
uri.port = http.port
|
97
97
|
|
98
|
-
if http.respond_to?(:use_ssl?) && http.use_ssl?
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
uri.scheme = if http.respond_to?(:use_ssl?) && http.use_ssl?
|
99
|
+
"https"
|
100
|
+
else
|
101
|
+
"http"
|
102
|
+
end
|
103
103
|
uri.to_s
|
104
104
|
end
|
105
105
|
|
106
106
|
def set_oauth_header
|
107
|
-
|
108
|
-
|
107
|
+
req[:head] ||= {}
|
108
|
+
req[:head].merge!("Authorization" => @oauth_helper.header)
|
109
109
|
end
|
110
110
|
|
111
111
|
def set_oauth_body
|
data/lib/oauth/client/helper.rb
CHANGED
@@ -14,9 +14,7 @@ module OAuth::Client
|
|
14
14
|
@options[:signature_method] ||= "HMAC-SHA1"
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
@options
|
19
|
-
end
|
17
|
+
attr_reader :options
|
20
18
|
|
21
19
|
def nonce
|
22
20
|
options[:nonce] ||= generate_key
|
@@ -40,26 +38,25 @@ module OAuth::Client
|
|
40
38
|
"oauth_session_handle" => options[:oauth_session_handle]
|
41
39
|
}
|
42
40
|
allowed_empty_params = options[:allow_empty_params]
|
43
|
-
if allowed_empty_params != true && !allowed_empty_params.
|
41
|
+
if allowed_empty_params != true && !allowed_empty_params.is_a?(Array)
|
44
42
|
allowed_empty_params = allowed_empty_params == false ? [] : [allowed_empty_params]
|
45
43
|
end
|
46
|
-
out.select! { |k,v| v.to_s != "" || allowed_empty_params == true || allowed_empty_params.include?(k) }
|
44
|
+
out.select! { |k, v| v.to_s != "" || allowed_empty_params == true || allowed_empty_params.include?(k) }
|
47
45
|
out
|
48
46
|
end
|
49
47
|
|
50
48
|
def signature(extra_options = {})
|
51
|
-
OAuth::Signature.sign(@request, { :
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
}.merge(extra_options) )
|
49
|
+
OAuth::Signature.sign(@request, { uri: options[:request_uri],
|
50
|
+
consumer: options[:consumer],
|
51
|
+
token: options[:token],
|
52
|
+
unsigned_parameters: options[:unsigned_parameters] }.merge(extra_options))
|
56
53
|
end
|
57
54
|
|
58
55
|
def signature_base_string(extra_options = {})
|
59
|
-
OAuth::Signature.signature_base_string(@request, { :
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
56
|
+
OAuth::Signature.signature_base_string(@request, { uri: options[:request_uri],
|
57
|
+
consumer: options[:consumer],
|
58
|
+
token: options[:token],
|
59
|
+
parameters: oauth_parameters }.merge(extra_options))
|
63
60
|
end
|
64
61
|
|
65
62
|
def token_request?
|
@@ -67,7 +64,7 @@ module OAuth::Client
|
|
67
64
|
end
|
68
65
|
|
69
66
|
def hash_body
|
70
|
-
@options[:body_hash] = OAuth::Signature.body_hash(@request, :
|
67
|
+
@options[:body_hash] = OAuth::Signature.body_hash(@request, parameters: oauth_parameters)
|
71
68
|
end
|
72
69
|
|
73
70
|
def amend_user_agent_header(headers)
|
@@ -82,9 +79,9 @@ module OAuth::Client
|
|
82
79
|
|
83
80
|
def header
|
84
81
|
parameters = oauth_parameters
|
85
|
-
parameters
|
82
|
+
parameters["oauth_signature"] = signature(options.merge(parameters: parameters))
|
86
83
|
|
87
|
-
header_params_str = parameters.sort.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(", ")
|
84
|
+
header_params_str = parameters.sort.map { |k, v| "#{k}=\"#{escape(v)}\"" }.join(", ")
|
88
85
|
|
89
86
|
realm = "realm=\"#{options[:realm]}\", " if options[:realm]
|
90
87
|
"OAuth #{realm}#{header_params_str}"
|
@@ -27,7 +27,7 @@ class Net::HTTPGenericRequest
|
|
27
27
|
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
|
28
28
|
@oauth_helper.amend_user_agent_header(self)
|
29
29
|
@oauth_helper.hash_body if oauth_body_hash_required?
|
30
|
-
|
30
|
+
send("set_oauth_#{helper_options[:scheme]}")
|
31
31
|
end
|
32
32
|
|
33
33
|
# Create a string suitable for signing for an HTTP request. This process involves parameter
|
@@ -52,34 +52,34 @@ class Net::HTTPGenericRequest
|
|
52
52
|
@oauth_helper.signature_base_string
|
53
53
|
end
|
54
54
|
|
55
|
-
private
|
55
|
+
private
|
56
56
|
|
57
57
|
def oauth_helper_options(http, consumer, token, options)
|
58
|
-
{ :
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
58
|
+
{ request_uri: oauth_full_request_uri(http, options),
|
59
|
+
consumer: consumer,
|
60
|
+
token: token,
|
61
|
+
scheme: "header",
|
62
|
+
signature_method: nil,
|
63
|
+
nonce: nil,
|
64
|
+
timestamp: nil }.merge(options)
|
65
65
|
end
|
66
66
|
|
67
|
-
def oauth_full_request_uri(http,options)
|
68
|
-
uri = URI.parse(
|
67
|
+
def oauth_full_request_uri(http, options)
|
68
|
+
uri = URI.parse(path)
|
69
69
|
uri.host = http.address
|
70
70
|
uri.port = http.port
|
71
71
|
|
72
72
|
if options[:request_endpoint] && options[:site]
|
73
|
-
is_https = options[:site].match(%r
|
74
|
-
uri.host = options[:site].gsub(%r
|
73
|
+
is_https = options[:site].match(%r{^https://})
|
74
|
+
uri.host = options[:site].gsub(%r{^https?://}, "")
|
75
75
|
uri.port ||= is_https ? 443 : 80
|
76
76
|
end
|
77
77
|
|
78
|
-
if http.respond_to?(:use_ssl?) && http.use_ssl?
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
uri.scheme = if http.respond_to?(:use_ssl?) && http.use_ssl?
|
79
|
+
"https"
|
80
|
+
else
|
81
|
+
"http"
|
82
|
+
end
|
83
83
|
|
84
84
|
uri.to_s
|
85
85
|
end
|
@@ -100,19 +100,19 @@ private
|
|
100
100
|
# base string.
|
101
101
|
|
102
102
|
def set_oauth_body
|
103
|
-
|
104
|
-
params_with_sig = @oauth_helper.parameters.merge(:
|
105
|
-
|
103
|
+
set_form_data(@oauth_helper.stringify_keys(@oauth_helper.parameters_with_oauth))
|
104
|
+
params_with_sig = @oauth_helper.parameters.merge(oauth_signature: @oauth_helper.signature)
|
105
|
+
set_form_data(@oauth_helper.stringify_keys(params_with_sig))
|
106
106
|
end
|
107
107
|
|
108
108
|
def set_oauth_query_string
|
109
|
-
oauth_params_str = @oauth_helper.oauth_parameters.map { |k,v| [escape(k), escape(v)]
|
109
|
+
oauth_params_str = @oauth_helper.oauth_parameters.map { |k, v| [escape(k), escape(v)].join("=") }.join("&")
|
110
110
|
uri = URI.parse(path)
|
111
|
-
if uri.query.to_s == ""
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
uri.query = if uri.query.to_s == ""
|
112
|
+
oauth_params_str
|
113
|
+
else
|
114
|
+
uri.query + "&" + oauth_params_str
|
115
|
+
end
|
116
116
|
|
117
117
|
@path = uri.to_s
|
118
118
|
|
data/lib/oauth/client.rb
CHANGED
File without changes
|