oauth 0.5.6 → 0.5.7.pre.pre1

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +454 -0
  3. data/CODE_OF_CONDUCT.md +84 -0
  4. data/LICENSE +18 -17
  5. data/README.md +211 -0
  6. data/TODO +0 -0
  7. data/bin/oauth +2 -2
  8. data/lib/oauth/cli/authorize_command.rb +0 -0
  9. data/lib/oauth/cli/base_command.rb +1 -1
  10. data/lib/oauth/cli/help_command.rb +0 -0
  11. data/lib/oauth/cli/query_command.rb +0 -0
  12. data/lib/oauth/cli/sign_command.rb +0 -0
  13. data/lib/oauth/cli/version_command.rb +0 -0
  14. data/lib/oauth/cli.rb +18 -18
  15. data/lib/oauth/client/action_controller_request.rb +7 -7
  16. data/lib/oauth/client/em_http.rb +99 -99
  17. data/lib/oauth/client/helper.rb +22 -22
  18. data/lib/oauth/client/net_http.rb +5 -5
  19. data/lib/oauth/client.rb +0 -0
  20. data/lib/oauth/consumer.rb +49 -38
  21. data/lib/oauth/errors/error.rb +0 -0
  22. data/lib/oauth/errors/problem.rb +0 -0
  23. data/lib/oauth/errors/unauthorized.rb +3 -1
  24. data/lib/oauth/errors.rb +3 -3
  25. data/lib/oauth/helper.rb +11 -7
  26. data/lib/oauth/oauth.rb +0 -0
  27. data/lib/oauth/oauth_test_helper.rb +4 -4
  28. data/lib/oauth/request_proxy/action_controller_request.rb +9 -9
  29. data/lib/oauth/request_proxy/action_dispatch_request.rb +1 -1
  30. data/lib/oauth/request_proxy/base.rb +16 -16
  31. data/lib/oauth/request_proxy/curb_request.rb +5 -5
  32. data/lib/oauth/request_proxy/em_http_request.rb +18 -12
  33. data/lib/oauth/request_proxy/jabber_request.rb +3 -3
  34. data/lib/oauth/request_proxy/mock_request.rb +1 -1
  35. data/lib/oauth/request_proxy/net_http.rb +9 -9
  36. data/lib/oauth/request_proxy/rack_request.rb +4 -4
  37. data/lib/oauth/request_proxy/rest_client_request.rb +7 -7
  38. data/lib/oauth/request_proxy/typhoeus_request.rb +7 -7
  39. data/lib/oauth/request_proxy.rb +0 -0
  40. data/lib/oauth/server.rb +2 -2
  41. data/lib/oauth/signature/base.rb +8 -6
  42. data/lib/oauth/signature/hmac/sha1.rb +4 -4
  43. data/lib/oauth/signature/hmac/sha256.rb +4 -4
  44. data/lib/oauth/signature/plaintext.rb +2 -2
  45. data/lib/oauth/signature/rsa/sha1.rb +3 -3
  46. data/lib/oauth/signature.rb +0 -0
  47. data/lib/oauth/token.rb +5 -5
  48. data/lib/oauth/tokens/access_token.rb +3 -3
  49. data/lib/oauth/tokens/consumer_token.rb +0 -0
  50. data/lib/oauth/tokens/request_token.rb +0 -0
  51. data/lib/oauth/tokens/server_token.rb +0 -0
  52. data/lib/oauth/tokens/token.rb +0 -0
  53. data/lib/oauth/version.rb +1 -1
  54. data/lib/oauth.rb +8 -7
  55. metadata +171 -64
  56. data/README.rdoc +0 -88
@@ -1,5 +1,5 @@
1
- require 'oauth/helper'
2
- require 'oauth/request_proxy/net_http'
1
+ require "oauth/helper"
2
+ require "oauth/request_proxy/net_http"
3
3
 
4
4
  class Net::HTTPGenericRequest
5
5
  include OAuth::Helper
@@ -58,7 +58,7 @@ private
58
58
  { :request_uri => oauth_full_request_uri(http,options),
59
59
  :consumer => consumer,
60
60
  :token => token,
61
- :scheme => 'header',
61
+ :scheme => "header",
62
62
  :signature_method => nil,
63
63
  :nonce => nil,
64
64
  :timestamp => nil }.merge(options)
@@ -71,7 +71,7 @@ private
71
71
 
72
72
  if options[:request_endpoint] && options[:site]
73
73
  is_https = options[:site].match(%r(^https://))
74
- uri.host = options[:site].gsub(%r(^https?://), '')
74
+ uri.host = options[:site].gsub(%r(^https?://), "")
75
75
  uri.port ||= is_https ? 443 : 80
76
76
  end
77
77
 
@@ -89,7 +89,7 @@ private
89
89
  end
90
90
 
91
91
  def set_oauth_header
92
- self['Authorization'] = @oauth_helper.header
92
+ self["Authorization"] = @oauth_helper.header
93
93
  end
94
94
 
95
95
  # FIXME: if you're using a POST body and query string parameters, this method
data/lib/oauth/client.rb CHANGED
File without changes
@@ -1,16 +1,16 @@
1
- require 'net/http'
2
- require 'net/https'
3
- require 'oauth/oauth'
4
- require 'oauth/client/net_http'
5
- require 'oauth/errors'
6
- require 'cgi'
1
+ require "net/http"
2
+ require "net/https"
3
+ require "oauth/oauth"
4
+ require "oauth/client/net_http"
5
+ require "oauth/errors"
6
+ require "cgi"
7
7
 
8
8
  module OAuth
9
9
  class Consumer
10
10
  # determine the certificate authority path to verify SSL certs
11
- if ENV['SSL_CERT_FILE']
12
- if File.exist?(ENV['SSL_CERT_FILE'])
13
- CA_FILE = ENV['SSL_CERT_FILE']
11
+ if ENV["SSL_CERT_FILE"]
12
+ if File.exist?(ENV["SSL_CERT_FILE"])
13
+ CA_FILE = ENV["SSL_CERT_FILE"]
14
14
  else
15
15
  raise "The SSL CERT provided does not exist."
16
16
  end
@@ -29,17 +29,17 @@ module OAuth
29
29
 
30
30
  @@default_options = {
31
31
  # Signature method used by server. Defaults to HMAC-SHA1
32
- :signature_method => 'HMAC-SHA1',
32
+ :signature_method => "HMAC-SHA1",
33
33
 
34
34
  # default paths on site. These are the same as the defaults set up by the generators
35
- :request_token_path => '/oauth/request_token',
36
- :authenticate_path => '/oauth/authenticate',
37
- :authorize_path => '/oauth/authorize',
38
- :access_token_path => '/oauth/access_token',
35
+ :request_token_path => "/oauth/request_token",
36
+ :authenticate_path => "/oauth/authenticate",
37
+ :authorize_path => "/oauth/authorize",
38
+ :access_token_path => "/oauth/access_token",
39
39
 
40
40
  :proxy => nil,
41
41
  # How do we send the oauth values to the server see
42
- # http://oauth.net/core/1.0/#consumer_req_param for more info
42
+ # https://oauth.net/core/1.0/#consumer_req_param for more info
43
43
  #
44
44
  # Possible values:
45
45
  #
@@ -157,11 +157,14 @@ module OAuth
157
157
  request_options[:oauth_callback] ||= OAuth::OUT_OF_BAND unless request_options[:exclude_callback]
158
158
 
159
159
  if block_given?
160
- response = token_request(http_method,
161
- (request_token_url? ? request_token_url : request_token_path),
162
- nil,
163
- request_options,
164
- *arguments, &block)
160
+ response = token_request(
161
+ http_method,
162
+ (request_token_url? ? request_token_url : request_token_path),
163
+ nil,
164
+ request_options,
165
+ *arguments,
166
+ &block
167
+ )
165
168
  else
166
169
  response = token_request(http_method, (request_token_url? ? request_token_url : request_token_path), nil, request_options, *arguments)
167
170
  end
@@ -190,7 +193,7 @@ module OAuth
190
193
  return nil if block_given? and yield(req) == :done
191
194
  rsp = http.request(req)
192
195
  # check for an error reported by the Problem Reporting extension
193
- # (http://wiki.oauth.net/ProblemReporting)
196
+ # (https://wiki.oauth.net/ProblemReporting)
194
197
  # note: a 200 may actually be an error; check for an oauth_problem key to be sure
195
198
  if !(headers = rsp.to_hash["www-authenticate"]).nil? &&
196
199
  (h = headers.select { |hdr| hdr =~ /^OAuth / }).any? &&
@@ -239,16 +242,18 @@ module OAuth
239
242
  end
240
243
  end
241
244
  when (300..399)
242
- # this is a redirect
243
- uri = URI.parse(response['location'])
245
+ # Parse redirect to follow
246
+ uri = URI.parse(response["location"])
244
247
  our_uri = URI.parse(site)
245
248
 
249
+ # Guard against infinite redirects
250
+ response.error! if uri.path == path && our_uri.host == uri.host
251
+
246
252
  if uri.path == path && our_uri.host != uri.host
247
253
  options[:site] = "#{uri.scheme}://#{uri.host}"
248
254
  @http = create_http
249
255
  end
250
256
 
251
- response.error! if uri.path == path && our_uri.host == uri.host # careful of those infinite redirects
252
257
  self.token_request(http_method, uri.path, token, request_options, arguments)
253
258
  when (400..499)
254
259
  raise OAuth::Unauthorized, response
@@ -338,18 +343,22 @@ module OAuth
338
343
  # Instantiates the http object
339
344
  def create_http(_url = nil)
340
345
 
341
-
342
346
  if !request_endpoint.nil?
343
347
  _url = request_endpoint
344
348
  end
345
349
 
346
-
347
- if _url.nil? || _url[0] =~ /^\//
348
- our_uri = URI.parse(site)
349
- else
350
- our_uri = URI.parse(_url)
351
- end
352
-
350
+ our_uri = if _url.nil? || _url[0] =~ /^\//
351
+ URI.parse(site)
352
+ else
353
+ your_uri = URI.parse(_url)
354
+ if your_uri.host.nil?
355
+ # If the _url is a path, missing the leading slash, then it won't have a host,
356
+ # and our_uri *must* have a host, so we parse site instead.
357
+ URI.parse(site)
358
+ else
359
+ your_uri
360
+ end
361
+ end
353
362
 
354
363
  if proxy.nil?
355
364
  http_object = Net::HTTP.new(our_uri.host, our_uri.port)
@@ -358,7 +367,7 @@ module OAuth
358
367
  http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
359
368
  end
360
369
 
361
- http_object.use_ssl = (our_uri.scheme == 'https')
370
+ http_object.use_ssl = (our_uri.scheme == "https")
362
371
 
363
372
  if @options[:no_verify]
364
373
  http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -374,6 +383,8 @@ module OAuth
374
383
  http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 60
375
384
  http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]
376
385
  http_object.ssl_version = @options[:ssl_version] if @options[:ssl_version]
386
+ http_object.cert = @options[:ssl_client_cert] if @options[:ssl_client_cert]
387
+ http_object.key = @options[:ssl_client_key] if @options[:ssl_client_key]
377
388
  http_object.set_debug_output(debug_output) if debug_output
378
389
 
379
390
  http_object
@@ -391,20 +402,20 @@ module OAuth
391
402
  # only add if the site host matches the current http object's host
392
403
  # (in case we've specified a full url for token requests)
393
404
  uri = URI.parse(site)
394
- path = uri.path + path if uri.path && uri.path != '/' && uri.host == http.address
405
+ path = uri.path + path if uri.path && uri.path != "/" && uri.host == http.address
395
406
 
396
407
  headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
397
408
 
398
409
  case http_method
399
410
  when :post
400
411
  request = Net::HTTP::Post.new(path,headers)
401
- request["Content-Length"] = '0' # Default to 0
412
+ request["Content-Length"] = "0" # Default to 0
402
413
  when :put
403
414
  request = Net::HTTP::Put.new(path,headers)
404
- request["Content-Length"] = '0' # Default to 0
415
+ request["Content-Length"] = "0" # Default to 0
405
416
  when :patch
406
417
  request = Net::HTTP::Patch.new(path,headers)
407
- request["Content-Length"] = '0' # Default to 0
418
+ request["Content-Length"] = "0" # Default to 0
408
419
  when :get
409
420
  request = Net::HTTP::Get.new(path,headers)
410
421
  when :delete
@@ -417,7 +428,7 @@ module OAuth
417
428
 
418
429
  if data.is_a?(Hash)
419
430
  request.body = OAuth::Helper.normalize(data)
420
- request.content_type = 'application/x-www-form-urlencoded'
431
+ request.content_type = "application/x-www-form-urlencoded"
421
432
  elsif data
422
433
  if data.respond_to?(:read)
423
434
  request.body_stream = data
File without changes
File without changes
@@ -6,7 +6,9 @@ module OAuth
6
6
  end
7
7
 
8
8
  def to_s
9
- [request.code, request.message] * " "
9
+ return "401 Unauthorized" if request.nil?
10
+
11
+ "#{request.code} #{request.message}"
10
12
  end
11
13
  end
12
14
  end
data/lib/oauth/errors.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'oauth/errors/error'
2
- require 'oauth/errors/unauthorized'
3
- require 'oauth/errors/problem'
1
+ require "oauth/errors/error"
2
+ require "oauth/errors/unauthorized"
3
+ require "oauth/errors/problem"
data/lib/oauth/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'openssl'
2
- require 'base64'
1
+ require "openssl"
2
+ require "base64"
3
3
 
4
4
  module OAuth
5
5
  module Helper
@@ -19,13 +19,13 @@ module OAuth
19
19
  end
20
20
 
21
21
  def unescape(value)
22
- URI::DEFAULT_PARSER.unescape(value.gsub('+', '%2B'))
22
+ URI::DEFAULT_PARSER.unescape(value.gsub("+", "%2B"))
23
23
  end
24
24
 
25
25
  # Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
26
26
  # characters removed.
27
27
  def generate_key(size=32)
28
- Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/, '')
28
+ Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/, "")
29
29
  end
30
30
 
31
31
  alias_method :generate_nonce, :generate_key
@@ -47,8 +47,12 @@ module OAuth
47
47
  # make sure the array has an element so we don't lose the key
48
48
  values << nil if values.empty?
49
49
  # multiple values were provided for a single key
50
- values.sort.collect do |v|
51
- [escape(k),escape(v)] * "="
50
+ if values[0].is_a?(Hash)
51
+ normalize_nested_query(values, k)
52
+ else
53
+ values.sort.collect do |v|
54
+ [escape(k),escape(v)] * "="
55
+ end
52
56
  end
53
57
  elsif values.is_a?(Hash)
54
58
  normalize_nested_query(values, k)
@@ -58,7 +62,7 @@ module OAuth
58
62
  end * "&"
59
63
  end
60
64
 
61
- #Returns a string representation of the Hash like in URL query string
65
+ # Returns a string representation of the Hash like in URL query string
62
66
  # build_nested_query({:level_1 => {:level_2 => ['value_1','value_2']}}, 'prefix'))
63
67
  # #=> ["prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_1", "prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_2"]
64
68
  def normalize_nested_query(value, prefix = nil)
data/lib/oauth/oauth.rb CHANGED
File without changes
@@ -1,5 +1,5 @@
1
- require 'action_controller'
2
- require 'action_controller/test_process'
1
+ require "action_controller"
2
+ require "action_controller/test_process"
3
3
 
4
4
  module OAuth
5
5
  module OAuthTestHelper
@@ -8,7 +8,7 @@ module OAuth
8
8
  incoming.request_uri = request.path
9
9
  incoming.host = request.uri.host
10
10
  incoming.env["SERVER_PORT"] = request.uri.port
11
- incoming.env['REQUEST_METHOD'] = request.http_method
11
+ incoming.env["REQUEST_METHOD"] = request.http_method
12
12
  incoming
13
13
  end
14
14
 
@@ -18,7 +18,7 @@ module OAuth
18
18
  incoming.host = request.uri.host
19
19
  incoming.env["HTTP_AUTHORIZATION"] = request.to_auth_string
20
20
  incoming.env["SERVER_PORT"] = request.uri.port
21
- incoming.env['REQUEST_METHOD'] = request.http_method
21
+ incoming.env["REQUEST_METHOD"] = request.http_method
22
22
  incoming
23
23
  end
24
24
  end
@@ -1,12 +1,12 @@
1
- require 'active_support'
1
+ require "active_support"
2
2
  require "active_support/version"
3
- require 'action_controller'
4
- require 'uri'
3
+ require "action_controller"
4
+ require "uri"
5
5
 
6
6
  if
7
7
  Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("3")
8
8
  then # rails 2.x
9
- require 'action_controller/request'
9
+ require "action_controller/request"
10
10
  unless ActionController::Request::HTTP_METHODS.include?("patch")
11
11
  ActionController::Request::HTTP_METHODS << "patch"
12
12
  ActionController::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
@@ -16,7 +16,7 @@ then # rails 2.x
16
16
  elsif
17
17
  Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("4")
18
18
  then # rails 3.x
19
- require 'action_dispatch/http/request'
19
+ require "action_dispatch/http/request"
20
20
  unless ActionDispatch::Request::HTTP_METHODS.include?("patch")
21
21
  ActionDispatch::Request::HTTP_METHODS << "patch"
22
22
  ActionDispatch::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
@@ -24,7 +24,7 @@ then # rails 3.x
24
24
  end
25
25
 
26
26
  else # rails 4.x and later - already has patch
27
- require 'action_dispatch/http/request'
27
+ require "action_dispatch/http/request"
28
28
  end
29
29
 
30
30
  module OAuth::RequestProxy
@@ -66,10 +66,10 @@ module OAuth::RequestProxy
66
66
  end
67
67
 
68
68
  params.
69
- join('&').split('&').
69
+ join("&").split("&").
70
70
  reject { |s| s.match(/\A\s*\z/) }.
71
- map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }.
72
- reject { |kv| kv[0] == 'oauth_signature'}
71
+ map { |p| p.split("=").map{|esc| CGI.unescape(esc)} }.
72
+ reject { |kv| kv[0] == "oauth_signature"}
73
73
  end
74
74
 
75
75
  def raw_post_signature?
@@ -1,4 +1,4 @@
1
- require 'oauth/request_proxy/rack_request'
1
+ require "oauth/request_proxy/rack_request"
2
2
 
3
3
  module OAuth::RequestProxy
4
4
  class ActionDispatchRequest < OAuth::RequestProxy::RackRequest
@@ -1,5 +1,5 @@
1
- require 'oauth/request_proxy'
2
- require 'oauth/helper'
1
+ require "oauth/request_proxy"
2
+ require "oauth/helper"
3
3
 
4
4
  module OAuth::RequestProxy
5
5
  class Base
@@ -20,41 +20,41 @@ module OAuth::RequestProxy
20
20
  ## OAuth parameters
21
21
 
22
22
  def oauth_callback
23
- parameters['oauth_callback']
23
+ parameters["oauth_callback"]
24
24
  end
25
25
 
26
26
  def oauth_consumer_key
27
- parameters['oauth_consumer_key']
27
+ parameters["oauth_consumer_key"]
28
28
  end
29
29
 
30
30
  def oauth_nonce
31
- parameters['oauth_nonce']
31
+ parameters["oauth_nonce"]
32
32
  end
33
33
 
34
34
  def oauth_signature
35
35
  # TODO can this be nil?
36
- [parameters['oauth_signature']].flatten.first || ""
36
+ [parameters["oauth_signature"]].flatten.first || ""
37
37
  end
38
38
 
39
39
  def oauth_signature_method
40
- case parameters['oauth_signature_method']
40
+ case parameters["oauth_signature_method"]
41
41
  when Array
42
- parameters['oauth_signature_method'].first
42
+ parameters["oauth_signature_method"].first
43
43
  else
44
- parameters['oauth_signature_method']
44
+ parameters["oauth_signature_method"]
45
45
  end
46
46
  end
47
47
 
48
48
  def oauth_timestamp
49
- parameters['oauth_timestamp']
49
+ parameters["oauth_timestamp"]
50
50
  end
51
51
 
52
52
  def oauth_token
53
- parameters['oauth_token']
53
+ parameters["oauth_token"]
54
54
  end
55
55
 
56
56
  def oauth_verifier
57
- parameters['oauth_verifier']
57
+ parameters["oauth_verifier"]
58
58
  end
59
59
 
60
60
  def oauth_version
@@ -140,15 +140,15 @@ module OAuth::RequestProxy
140
140
 
141
141
  # Authorization header for OAuth
142
142
  def oauth_header(options = {})
143
- header_params_str = oauth_parameters.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(', ')
143
+ header_params_str = oauth_parameters.map { |k,v| "#{k}=\"#{escape(v)}\"" }.join(", ")
144
144
 
145
145
  realm = "realm=\"#{options[:realm]}\", " if options[:realm]
146
146
  "OAuth #{realm}#{header_params_str}"
147
147
  end
148
148
 
149
149
  def query_string_blank?
150
- if uri = request.env['REQUEST_URI']
151
- uri.split('?', 2)[1].nil?
150
+ if uri = request.env["REQUEST_URI"]
151
+ uri.split("?", 2)[1].nil?
152
152
  else
153
153
  request.query_string.match(/\A\s*\z/)
154
154
  end
@@ -161,7 +161,7 @@ module OAuth::RequestProxy
161
161
  next unless request.env.include?(header)
162
162
 
163
163
  header = request.env[header]
164
- next unless header[0,6] == 'OAuth '
164
+ next unless header[0,6] == "OAuth "
165
165
 
166
166
  # parse the header into a Hash
167
167
  oauth_params = OAuth::Helper.parse_header(header)
@@ -1,7 +1,7 @@
1
- require 'oauth/request_proxy/base'
2
- require 'curb'
3
- require 'uri'
4
- require 'cgi'
1
+ require "oauth/request_proxy/base"
2
+ require "curb"
3
+ require "uri"
4
+ require "cgi"
5
5
 
6
6
  module OAuth::RequestProxy::Curl
7
7
  class Easy < OAuth::RequestProxy::Base
@@ -42,7 +42,7 @@ module OAuth::RequestProxy::Curl
42
42
  post_body = {}
43
43
 
44
44
  # Post params are only used if posting form data
45
- if (request.headers['Content-Type'] && request.headers['Content-Type'].to_s.downcase.start_with?("application/x-www-form-urlencoded"))
45
+ if (request.headers["Content-Type"] && request.headers["Content-Type"].to_s.downcase.start_with?("application/x-www-form-urlencoded"))
46
46
 
47
47
  request.post_body.split("&").each do |str|
48
48
  param = str.split("=")
@@ -1,7 +1,7 @@
1
- require 'oauth/request_proxy/base'
1
+ require "oauth/request_proxy/base"
2
2
  # em-http also uses adddressable so there is no need to require uri.
3
- require 'em-http'
4
- require 'cgi'
3
+ require "em-http"
4
+ require "cgi"
5
5
 
6
6
  module OAuth::RequestProxy::EventMachine
7
7
  class HttpRequest < OAuth::RequestProxy::Base
@@ -14,11 +14,11 @@ module OAuth::RequestProxy::EventMachine
14
14
  # Request in this con
15
15
 
16
16
  def method
17
- request.method
17
+ request.req[:method]
18
18
  end
19
19
 
20
20
  def uri
21
- request.normalize_uri.to_s
21
+ request.conn.normalize.to_s
22
22
  end
23
23
 
24
24
  def parameters
@@ -36,14 +36,20 @@ module OAuth::RequestProxy::EventMachine
36
36
  end
37
37
 
38
38
  def query_parameters
39
- CGI.parse(request.normalize_uri.query.to_s)
39
+ quer = request.req[:query]
40
+ hash_quer = if quer.respond_to?(:merge)
41
+ quer
42
+ else
43
+ CGI.parse(quer.to_s)
44
+ end
45
+ CGI.parse(request.conn.query.to_s).merge(hash_quer)
40
46
  end
41
47
 
42
48
  def post_parameters
43
- headers = request.options[:head] || {}
44
- form_encoded = headers['Content-Type'].to_s.downcase.start_with?("application/x-www-form-urlencoded")
45
- if ['POST', 'PUT'].include?(method) && form_encoded
46
- CGI.parse(request.normalize_body.to_s)
49
+ headers = request.req[:head] || {}
50
+ form_encoded = headers["Content-Type"].to_s.downcase.start_with?("application/x-www-form-urlencoded")
51
+ if ["POST", "PUT"].include?(method) && form_encoded
52
+ CGI.parse(request.normalize_body(request.req[:body]).to_s)
47
53
  else
48
54
  {}
49
55
  end
@@ -53,9 +59,9 @@ module OAuth::RequestProxy::EventMachine
53
59
  extra_params.compact.each do |params_pairs|
54
60
  params_pairs.each_pair do |key, value|
55
61
  if params.has_key?(key)
56
- params[key] += value
62
+ params[key.to_s] += value
57
63
  else
58
- params[key] = [value].flatten
64
+ params[key.to_s] = [value].flatten
59
65
  end
60
66
  end
61
67
  end
@@ -1,5 +1,5 @@
1
- require 'xmpp4r'
2
- require 'oauth/request_proxy/base'
1
+ require "xmpp4r"
2
+ require "oauth/request_proxy/base"
3
3
 
4
4
  module OAuth
5
5
  module RequestProxy
@@ -13,7 +13,7 @@ module OAuth
13
13
 
14
14
  @params = {}
15
15
 
16
- oauth = @request.get_elements('//oauth').first
16
+ oauth = @request.get_elements("//oauth").first
17
17
  return @params unless oauth
18
18
 
19
19
  %w( oauth_token oauth_consumer_key oauth_signature_method oauth_signature
@@ -1,4 +1,4 @@
1
- require 'oauth/request_proxy/base'
1
+ require "oauth/request_proxy/base"
2
2
 
3
3
  module OAuth
4
4
  module RequestProxy
@@ -1,7 +1,7 @@
1
- require 'oauth/request_proxy/base'
2
- require 'net/http'
3
- require 'uri'
4
- require 'cgi'
1
+ require "oauth/request_proxy/base"
2
+ require "net/http"
3
+ require "uri"
4
+ require "cgi"
5
5
 
6
6
  module OAuth::RequestProxy::Net
7
7
  module HTTP
@@ -48,12 +48,12 @@ module OAuth::RequestProxy::Net
48
48
 
49
49
  def query_string
50
50
  params = [ query_params, auth_header_params ]
51
- params << post_params if (method.to_s.upcase == 'POST' || method.to_s.upcase == 'PUT') && form_url_encoded?
52
- params.compact.join('&')
51
+ params << post_params if (method.to_s.upcase == "POST" || method.to_s.upcase == "PUT") && form_url_encoded?
52
+ params.compact.join("&")
53
53
  end
54
54
 
55
55
  def form_url_encoded?
56
- request['Content-Type'] != nil && request['Content-Type'].to_s.downcase.start_with?('application/x-www-form-urlencoded')
56
+ request["Content-Type"] != nil && request["Content-Type"].to_s.downcase.start_with?("application/x-www-form-urlencoded")
57
57
  end
58
58
 
59
59
  def query_params
@@ -65,8 +65,8 @@ module OAuth::RequestProxy::Net
65
65
  end
66
66
 
67
67
  def auth_header_params
68
- return nil unless request['Authorization'] && request['Authorization'][0,5] == 'OAuth'
69
- request['Authorization']
68
+ return nil unless request["Authorization"] && request["Authorization"][0,5] == "OAuth"
69
+ request["Authorization"]
70
70
  end
71
71
  end
72
72
  end
@@ -1,6 +1,6 @@
1
- require 'oauth/request_proxy/base'
2
- require 'uri'
3
- require 'rack'
1
+ require "oauth/request_proxy/base"
2
+ require "uri"
3
+ require "rack"
4
4
 
5
5
  module OAuth::RequestProxy
6
6
  class RackRequest < OAuth::RequestProxy::Base
@@ -24,7 +24,7 @@ module OAuth::RequestProxy
24
24
  end
25
25
 
26
26
  def signature
27
- parameters['oauth_signature']
27
+ parameters["oauth_signature"]
28
28
  end
29
29
 
30
30
  protected