oauth 0.5.6 → 1.1.5
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
- checksums.yaml.gz.sig +4 -0
- data/CHANGELOG.md +848 -0
- data/CITATION.cff +20 -0
- data/CODE_OF_CONDUCT.md +134 -0
- data/CONTRIBUTING.md +218 -0
- data/FUNDING.md +77 -0
- data/LICENSE.txt +22 -0
- data/README.md +662 -0
- data/REEK +2 -0
- data/RUBOCOP.md +71 -0
- data/SECURITY.md +24 -0
- data/lib/oauth/auth_sanitizer.rb +36 -0
- data/lib/oauth/client/action_controller_request.rb +33 -22
- data/lib/oauth/client/em_http.rb +110 -103
- data/lib/oauth/client/helper.rb +87 -82
- data/lib/oauth/client/net_http.rb +140 -107
- data/lib/oauth/client.rb +2 -0
- data/lib/oauth/consumer.rb +222 -141
- data/lib/oauth/errors/error.rb +2 -0
- data/lib/oauth/errors/problem.rb +4 -1
- data/lib/oauth/errors/unauthorized.rb +7 -1
- data/lib/oauth/errors.rb +5 -3
- data/lib/oauth/helper.rb +48 -18
- data/lib/oauth/oauth.rb +31 -7
- data/lib/oauth/oauth_test_helper.rb +6 -4
- data/lib/oauth/optional.rb +20 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +53 -71
- data/lib/oauth/request_proxy/action_dispatch_request.rb +42 -4
- data/lib/oauth/request_proxy/base.rb +146 -131
- data/lib/oauth/request_proxy/curb_request.rb +49 -43
- data/lib/oauth/request_proxy/em_http_request.rb +60 -49
- data/lib/oauth/request_proxy/jabber_request.rb +19 -9
- data/lib/oauth/request_proxy/mock_request.rb +5 -3
- data/lib/oauth/request_proxy/net_http.rb +61 -54
- data/lib/oauth/request_proxy/rack_request.rb +31 -31
- data/lib/oauth/request_proxy/rest_client_request.rb +55 -50
- data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
- data/lib/oauth/request_proxy.rb +21 -14
- data/lib/oauth/server.rb +18 -12
- data/lib/oauth/signature/base.rb +88 -71
- data/lib/oauth/signature/hmac/sha1.rb +16 -10
- data/lib/oauth/signature/hmac/sha256.rb +16 -10
- data/lib/oauth/signature/plaintext.rb +18 -20
- data/lib/oauth/signature/rsa/sha1.rb +53 -38
- data/lib/oauth/signature.rb +41 -34
- data/lib/oauth/token.rb +7 -5
- data/lib/oauth/tokens/access_token.rb +6 -4
- data/lib/oauth/tokens/consumer_token.rb +11 -7
- data/lib/oauth/tokens/request_token.rb +17 -10
- data/lib/oauth/tokens/server_token.rb +2 -1
- data/lib/oauth/tokens/token.rb +15 -1
- data/lib/oauth/version.rb +6 -1
- data/lib/oauth.rb +18 -9
- data/sig/oauth/consumer.rbs +9 -0
- data/sig/oauth/signature/base.rbs +12 -0
- data/sig/oauth/tokens/token.rbs +8 -0
- data.tar.gz.sig +3 -0
- metadata +301 -82
- metadata.gz.sig +2 -0
- data/LICENSE +0 -20
- data/README.rdoc +0 -88
- data/TODO +0 -32
- data/bin/oauth +0 -11
- data/lib/oauth/cli/authorize_command.rb +0 -71
- data/lib/oauth/cli/base_command.rb +0 -208
- data/lib/oauth/cli/help_command.rb +0 -22
- data/lib/oauth/cli/query_command.rb +0 -25
- data/lib/oauth/cli/sign_command.rb +0 -81
- data/lib/oauth/cli/version_command.rb +0 -7
- data/lib/oauth/cli.rb +0 -56
|
@@ -1,178 +1,193 @@
|
|
|
1
|
-
|
|
2
|
-
require 'oauth/helper'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
include OAuth::Helper
|
|
3
|
+
require "oauth/request_proxy"
|
|
4
|
+
require "oauth/helper"
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
module OAuth
|
|
7
|
+
module RequestProxy
|
|
8
|
+
class Base
|
|
9
|
+
include OAuth::Helper
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
class << self
|
|
12
|
+
def proxies(klass)
|
|
13
|
+
OAuth::RequestProxy.available_proxies[klass] = self
|
|
14
|
+
end
|
|
15
|
+
end
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
@request = request
|
|
16
|
-
@unsigned_parameters = (options[:unsigned_parameters] || []).map {|param| param.to_s}
|
|
17
|
-
@options = options
|
|
18
|
-
end
|
|
17
|
+
attr_accessor :request, :options, :unsigned_parameters
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
def initialize(request, options = {})
|
|
20
|
+
@request = request
|
|
21
|
+
@unsigned_parameters = (options[:unsigned_parameters] || []).map(&:to_s)
|
|
22
|
+
@options = options
|
|
23
|
+
end
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
parameters['oauth_callback']
|
|
24
|
-
end
|
|
25
|
+
## OAuth parameters
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
def oauth_callback
|
|
28
|
+
[parameters["oauth_callback"]].flatten.first
|
|
29
|
+
end
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
def oauth_consumer_key
|
|
32
|
+
[parameters["oauth_consumer_key"]].flatten.first
|
|
33
|
+
end
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
35
|
+
def oauth_nonce
|
|
36
|
+
[parameters["oauth_nonce"]].flatten.first
|
|
37
|
+
end
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
parameters['oauth_signature_method'].first
|
|
43
|
-
else
|
|
44
|
-
parameters['oauth_signature_method']
|
|
39
|
+
def oauth_signature
|
|
40
|
+
# TODO: can this be nil?
|
|
41
|
+
[parameters["oauth_signature"]].flatten.first || ""
|
|
45
42
|
end
|
|
46
|
-
end
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
def oauth_signature_method
|
|
45
|
+
[parameters["oauth_signature_method"]].flatten.first
|
|
46
|
+
end
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
def oauth_timestamp
|
|
49
|
+
[parameters["oauth_timestamp"]].flatten.first
|
|
50
|
+
end
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
def oauth_token
|
|
53
|
+
[parameters["oauth_token"]].flatten.first
|
|
54
|
+
end
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
# OAuth 1.0a only: value returned to the Consumer after user authorization
|
|
57
|
+
# and required when exchanging a Request Token for an Access Token.
|
|
58
|
+
# Not present in OAuth 1.0 flows.
|
|
59
|
+
def oauth_verifier
|
|
60
|
+
[parameters["oauth_verifier"]].flatten.first
|
|
61
|
+
end
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
alias_method :nonce, :oauth_nonce
|
|
68
|
-
alias_method :timestamp, :oauth_timestamp
|
|
69
|
-
alias_method :signature, :oauth_signature
|
|
70
|
-
alias_method :signature_method, :oauth_signature_method
|
|
63
|
+
def oauth_version
|
|
64
|
+
[parameters["oauth_version"]].flatten.first
|
|
65
|
+
end
|
|
71
66
|
|
|
72
|
-
|
|
67
|
+
# TODO: deprecate these
|
|
68
|
+
alias_method :consumer_key, :oauth_consumer_key
|
|
69
|
+
alias_method :token, :oauth_token
|
|
70
|
+
alias_method :nonce, :oauth_nonce
|
|
71
|
+
alias_method :timestamp, :oauth_timestamp
|
|
72
|
+
alias_method :signature, :oauth_signature
|
|
73
|
+
alias_method :signature_method, :oauth_signature_method
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
raise NotImplementedError, "Must be implemented by subclasses"
|
|
76
|
-
end
|
|
75
|
+
## Parameter accessors
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
def parameters
|
|
78
|
+
raise NotImplementedError, "Must be implemented by subclasses"
|
|
79
|
+
end
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
def parameters_for_signature
|
|
82
|
+
parameters.select { |k, _v| !signature_and_unsigned_parameters.include?(k) }
|
|
83
|
+
end
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
def oauth_parameters
|
|
86
|
+
parameters.select { |k, v| OAuth::PARAMETERS.include?(k) && !v.nil? && v != "" }
|
|
87
|
+
end
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
def non_oauth_parameters
|
|
90
|
+
parameters.select { |k, _v| !OAuth::PARAMETERS.include?(k) }
|
|
91
|
+
end
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"#{u.scheme.downcase}://#{u.host.downcase}#{(u.scheme.downcase == 'http' && u.port != 80) || (u.scheme.downcase == 'https' && u.port != 443) ? ":#{u.port}" : ""}#{(u.path && u.path != '') ? u.path : '/'}"
|
|
98
|
-
end
|
|
93
|
+
def signature_and_unsigned_parameters
|
|
94
|
+
unsigned_parameters + ["oauth_signature"]
|
|
95
|
+
end
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
# See 9.1.2 in specs
|
|
98
|
+
def normalized_uri
|
|
99
|
+
u = URI.parse(uri)
|
|
100
|
+
"#{u.scheme.downcase}://#{u.host.downcase}#{":#{u.port}" if (u.scheme.casecmp("http").zero? && u.port != 80) || (u.scheme.casecmp("https").zero? && u.port != 443)}#{(u.path && u.path != "") ? u.path : "/"}"
|
|
101
|
+
end
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
# See 9.1.1. in specs Normalize Request Parameters
|
|
104
|
+
def normalized_parameters
|
|
105
|
+
normalize(parameters_for_signature)
|
|
106
|
+
end
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
signature
|
|
113
|
-
end
|
|
108
|
+
def sign(options = {})
|
|
109
|
+
OAuth::Signature.sign(self, options)
|
|
110
|
+
end
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
def sign!(options = {})
|
|
113
|
+
parameters["oauth_signature"] = sign(options)
|
|
114
|
+
@signed = true
|
|
115
|
+
signature
|
|
116
|
+
end
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
# See 9.1 in specs
|
|
119
|
+
def signature_base_string
|
|
120
|
+
base = [method, normalized_uri, normalized_parameters]
|
|
121
|
+
base.map { |v| escape(v) }.join("&")
|
|
122
|
+
end
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
# Has this request been signed yet?
|
|
125
|
+
def signed?
|
|
126
|
+
@signed
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# URI, including OAuth parameters
|
|
130
|
+
def signed_uri(with_oauth: true)
|
|
131
|
+
if signed?
|
|
132
|
+
params = if with_oauth
|
|
133
|
+
parameters
|
|
134
|
+
else
|
|
135
|
+
non_oauth_parameters
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
[uri, normalize(params)].join("?")
|
|
131
139
|
else
|
|
132
|
-
|
|
140
|
+
warn("This request has not yet been signed!")
|
|
133
141
|
end
|
|
134
|
-
|
|
135
|
-
[uri, normalize(params)] * "?"
|
|
136
|
-
else
|
|
137
|
-
STDERR.puts "This request has not yet been signed!"
|
|
138
142
|
end
|
|
139
|
-
end
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
# Authorization header for OAuth
|
|
145
|
+
def oauth_header(options = {})
|
|
146
|
+
header_params_str = oauth_parameters.map { |k, v| "#{k}=\"#{escape(v)}\"" }.join(", ")
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
realm = "realm=\"#{options[:realm]}\", " if options[:realm]
|
|
149
|
+
"OAuth #{realm}#{header_params_str}"
|
|
150
|
+
end
|
|
148
151
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
def query_string_blank?
|
|
153
|
+
if (uri = request.env["REQUEST_URI"])
|
|
154
|
+
uri.split("?", 2)[1].nil?
|
|
155
|
+
else
|
|
156
|
+
request.query_string.match(/\A\s*\z/)
|
|
157
|
+
end
|
|
154
158
|
end
|
|
155
|
-
end
|
|
156
159
|
|
|
157
|
-
|
|
160
|
+
protected
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
def header_params
|
|
163
|
+
%w[X-HTTP_AUTHORIZATION Authorization HTTP_AUTHORIZATION].each do |header|
|
|
164
|
+
next unless request.env.include?(header)
|
|
162
165
|
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
header = request.env[header]
|
|
167
|
+
next unless header[0, 6] == "OAuth "
|
|
165
168
|
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
# parse the header into a Hash
|
|
170
|
+
oauth_params = OAuth::Helper.parse_header(header)
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
# remove non-OAuth parameters
|
|
173
|
+
oauth_params.select! { |k, _v| k =~ /^oauth_/ }
|
|
171
174
|
|
|
172
|
-
|
|
175
|
+
return oauth_params
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
{}
|
|
173
179
|
end
|
|
174
180
|
|
|
175
|
-
|
|
181
|
+
# Utility to make parameter values array-style (or keep nil) so that
|
|
182
|
+
# subclasses can rely on array values for parameter merging/signing.
|
|
183
|
+
# Mirrors the implementation previously present in
|
|
184
|
+
# ActionDispatchRequest#wrap_values.
|
|
185
|
+
def wrap_values(hash)
|
|
186
|
+
return {} unless hash
|
|
187
|
+
hash.each_with_object({}) do |(k, v), acc|
|
|
188
|
+
acc[k] = (v.is_a?(Array) || v.nil?) ? v : [v]
|
|
189
|
+
end
|
|
190
|
+
end
|
|
176
191
|
end
|
|
177
192
|
end
|
|
178
193
|
end
|
|
@@ -1,55 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "oauth/request_proxy/base"
|
|
4
|
+
require "curb"
|
|
5
|
+
require "uri"
|
|
6
|
+
require "cgi"
|
|
7
|
+
|
|
8
|
+
module OAuth
|
|
9
|
+
module RequestProxy
|
|
10
|
+
module Curl
|
|
11
|
+
class Easy < OAuth::RequestProxy::Base
|
|
12
|
+
# Proxy for signing Curl::Easy requests
|
|
13
|
+
# Usage example:
|
|
14
|
+
# oauth_params = {:consumer => oauth_consumer, :token => access_token}
|
|
15
|
+
# req = Curl::Easy.new(uri)
|
|
16
|
+
# oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
|
|
17
|
+
# req.headers.merge!({"Authorization" => oauth_helper.header})
|
|
18
|
+
# req.http_get
|
|
19
|
+
# response = req.body_str
|
|
20
|
+
proxies ::Curl::Easy
|
|
21
|
+
|
|
22
|
+
def method
|
|
23
|
+
nil
|
|
24
|
+
end
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
def uri
|
|
27
|
+
options[:uri].to_s
|
|
28
|
+
end
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
def parameters
|
|
31
|
+
if options[:clobber_request]
|
|
32
|
+
options[:parameters]
|
|
33
|
+
else
|
|
34
|
+
post_parameters.merge(query_parameters).merge(options[:parameters] || {})
|
|
35
|
+
end
|
|
36
|
+
end
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
private
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
def query_parameters
|
|
41
|
+
query = URI.parse(request.url).query
|
|
42
|
+
(query ? CGI.parse(query) : {})
|
|
43
|
+
end
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
def post_parameters
|
|
46
|
+
post_body = {}
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
# Post params are only used if posting form data
|
|
49
|
+
if request.headers["Content-Type"] && request.headers["Content-Type"].to_s.downcase.start_with?("application/x-www-form-urlencoded")
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
request.post_body.split("&").each do |str|
|
|
52
|
+
param = str.split("=")
|
|
53
|
+
post_body[param[0]] = param[1]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
post_body
|
|
50
57
|
end
|
|
51
58
|
end
|
|
52
|
-
post_body
|
|
53
59
|
end
|
|
54
60
|
end
|
|
55
61
|
end
|
|
@@ -1,66 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
# em-http also uses adddressable so there is no need to require uri.
|
|
3
|
-
require 'em-http'
|
|
4
|
-
require 'cgi'
|
|
1
|
+
# frozen_string_literal: true
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require "oauth/request_proxy/base"
|
|
4
|
+
require "oauth/optional"
|
|
5
|
+
require "cgi"
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if OAuth::Optional.em_http_available?
|
|
8
|
+
module OAuth
|
|
9
|
+
module RequestProxy
|
|
10
|
+
module EventMachine
|
|
11
|
+
class HttpRequest < OAuth::RequestProxy::Base
|
|
12
|
+
# A Proxy for use when you need to sign EventMachine::HttpClient instances.
|
|
13
|
+
# It needs to be called once the client is construct but before data is sent.
|
|
14
|
+
# Also see oauth/client/em-http
|
|
15
|
+
proxies ::EventMachine::HttpClient
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
# Request in this con
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
def method
|
|
20
|
+
request.req[:method]
|
|
21
|
+
end
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
def uri
|
|
24
|
+
request.conn.normalize.to_s
|
|
25
|
+
end
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
def parameters
|
|
28
|
+
if options[:clobber_request]
|
|
29
|
+
options[:parameters]
|
|
30
|
+
else
|
|
31
|
+
all_parameters
|
|
32
|
+
end
|
|
33
|
+
end
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
protected
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
def all_parameters
|
|
38
|
+
merged_parameters({}, post_parameters, query_parameters, options[:parameters])
|
|
39
|
+
end
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
def query_parameters
|
|
42
|
+
quer = request.req[:query]
|
|
43
|
+
hash_quer = if quer.respond_to?(:merge)
|
|
44
|
+
quer
|
|
45
|
+
else
|
|
46
|
+
CGI.parse(quer.to_s)
|
|
47
|
+
end
|
|
48
|
+
CGI.parse(request.conn.query.to_s).merge(hash_quer)
|
|
49
|
+
end
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
def post_parameters
|
|
52
|
+
headers = request.req[:head] || {}
|
|
53
|
+
form_encoded = headers["Content-Type"].to_s.downcase.start_with?("application/x-www-form-urlencoded")
|
|
54
|
+
if %w[POST PUT].include?(method) && form_encoded
|
|
55
|
+
CGI.parse(request.normalize_body(request.req[:body]).to_s)
|
|
56
|
+
else
|
|
57
|
+
{}
|
|
58
|
+
end
|
|
59
|
+
end
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
def merged_parameters(params, *extra_params)
|
|
62
|
+
extra_params.compact.each do |params_pairs|
|
|
63
|
+
params_pairs.each_pair do |key, value|
|
|
64
|
+
if params.key?(key)
|
|
65
|
+
params[key.to_s] += value
|
|
66
|
+
else
|
|
67
|
+
params[key.to_s] = [value].flatten
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
params
|
|
59
72
|
end
|
|
60
73
|
end
|
|
61
74
|
end
|
|
62
|
-
params
|
|
63
75
|
end
|
|
64
|
-
|
|
65
76
|
end
|
|
66
77
|
end
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "xmpp4r"
|
|
4
|
+
require "oauth/request_proxy/base"
|
|
3
5
|
|
|
4
6
|
module OAuth
|
|
5
7
|
module RequestProxy
|
|
6
8
|
class JabberRequest < OAuth::RequestProxy::Base
|
|
7
|
-
proxies Jabber::Iq
|
|
8
|
-
proxies Jabber::Presence
|
|
9
|
-
proxies Jabber::Message
|
|
9
|
+
proxies ::Jabber::Iq
|
|
10
|
+
proxies ::Jabber::Presence
|
|
11
|
+
proxies ::Jabber::Message
|
|
10
12
|
|
|
11
13
|
def parameters
|
|
12
14
|
return @params if @params
|
|
13
15
|
|
|
14
16
|
@params = {}
|
|
15
17
|
|
|
16
|
-
oauth = @request.get_elements(
|
|
18
|
+
oauth = @request.get_elements("//oauth").first
|
|
17
19
|
return @params unless oauth
|
|
18
20
|
|
|
19
|
-
%w
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
%w[
|
|
22
|
+
oauth_token
|
|
23
|
+
oauth_consumer_key
|
|
24
|
+
oauth_signature_method
|
|
25
|
+
oauth_signature
|
|
26
|
+
oauth_timestamp
|
|
27
|
+
oauth_nonce
|
|
28
|
+
oauth_version
|
|
29
|
+
].each do |param|
|
|
30
|
+
next unless (element = oauth.first_element(param))
|
|
31
|
+
|
|
22
32
|
@params[param] = element.text
|
|
23
33
|
end
|
|
24
34
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "oauth/request_proxy/base"
|
|
2
4
|
|
|
3
5
|
module OAuth
|
|
4
6
|
module RequestProxy
|
|
@@ -18,7 +20,7 @@ module OAuth
|
|
|
18
20
|
# :consumer_secret => oauth_consumer_secret,
|
|
19
21
|
# :token_secret => oauth_token_secret,
|
|
20
22
|
class MockRequest < OAuth::RequestProxy::Base
|
|
21
|
-
proxies Hash
|
|
23
|
+
proxies ::Hash
|
|
22
24
|
|
|
23
25
|
def parameters
|
|
24
26
|
@request["parameters"]
|
|
@@ -30,7 +32,7 @@ module OAuth
|
|
|
30
32
|
|
|
31
33
|
def normalized_uri
|
|
32
34
|
super
|
|
33
|
-
rescue
|
|
35
|
+
rescue StandardError
|
|
34
36
|
# if this is a non-standard URI, it may not parse properly
|
|
35
37
|
# in that case, assume that it's already been normalized
|
|
36
38
|
uri
|