oauth 0.5.14 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -31
- data/CONTRIBUTING.md +2 -2
- data/README.md +65 -61
- data/SECURITY.md +5 -13
- data/bin/oauth +8 -4
- data/lib/oauth/cli/authorize_command.rb +58 -54
- data/lib/oauth/cli/base_command.rb +163 -159
- data/lib/oauth/cli/help_command.rb +9 -5
- data/lib/oauth/cli/query_command.rb +26 -17
- data/lib/oauth/cli/sign_command.rb +58 -52
- data/lib/oauth/cli/version_command.rb +8 -4
- data/lib/oauth/cli.rb +2 -0
- data/lib/oauth/client/action_controller_request.rb +4 -1
- data/lib/oauth/client/em_http.rb +3 -1
- data/lib/oauth/client/helper.rb +76 -72
- data/lib/oauth/client/net_http.rb +111 -104
- data/lib/oauth/client.rb +2 -0
- data/lib/oauth/consumer.rb +50 -32
- data/lib/oauth/errors/error.rb +2 -0
- data/lib/oauth/errors/problem.rb +3 -0
- data/lib/oauth/errors/unauthorized.rb +4 -0
- data/lib/oauth/errors.rb +2 -0
- data/lib/oauth/helper.rb +9 -5
- data/lib/oauth/oauth.rb +4 -2
- data/lib/oauth/oauth_test_helper.rb +2 -0
- data/lib/oauth/request_proxy/base.rb +4 -4
- data/lib/oauth/request_proxy/mock_request.rb +1 -1
- data/lib/oauth/request_proxy/net_http.rb +8 -8
- data/lib/oauth/request_proxy/rest_client_request.rb +4 -3
- data/lib/oauth/request_proxy.rb +4 -1
- data/lib/oauth/server.rb +8 -4
- data/lib/oauth/signature/base.rb +73 -65
- data/lib/oauth/signature/hmac/sha1.rb +15 -9
- data/lib/oauth/signature/hmac/sha256.rb +15 -9
- data/lib/oauth/signature/plaintext.rb +18 -20
- data/lib/oauth/signature/rsa/sha1.rb +46 -38
- data/lib/oauth/signature.rb +3 -0
- data/lib/oauth/token.rb +2 -0
- data/lib/oauth/tokens/access_token.rb +2 -0
- data/lib/oauth/tokens/consumer_token.rb +2 -0
- data/lib/oauth/tokens/request_token.rb +5 -2
- data/lib/oauth/tokens/server_token.rb +2 -0
- data/lib/oauth/tokens/token.rb +2 -0
- data/lib/oauth/version.rb +5 -1
- data/lib/oauth.rb +8 -2
- metadata +28 -56
@@ -1,209 +1,213 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OAuth
|
4
|
+
class CLI
|
5
|
+
class BaseCommand
|
6
|
+
def initialize(stdout, stdin, stderr, arguments)
|
7
|
+
@stdout = stdout
|
8
|
+
@stdin = stdin
|
9
|
+
@stderr = stderr
|
10
|
+
|
11
|
+
@options = {}
|
12
|
+
option_parser.parse!(arguments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
missing = required_options - options.keys
|
17
|
+
if missing.empty?
|
18
|
+
_run
|
19
|
+
else
|
20
|
+
show_missing(missing)
|
21
|
+
puts option_parser.help
|
22
|
+
end
|
19
23
|
end
|
20
|
-
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def required_options
|
26
|
+
[]
|
27
|
+
end
|
25
28
|
|
26
|
-
|
29
|
+
protected
|
27
30
|
|
28
|
-
|
31
|
+
attr_reader :options
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def show_missing(array)
|
34
|
+
array = array.map { |s| "--#{s}" }.join(" ")
|
35
|
+
OAuth::CLI.puts_red "Options missing to OAuth CLI: #{array}"
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
def xmpp?
|
39
|
+
options[:xmpp]
|
40
|
+
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
def verbose?
|
43
|
+
options[:verbose]
|
44
|
+
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
def puts(string = nil)
|
47
|
+
@stdout.puts(string)
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
def alert(string = nil)
|
51
|
+
@stderr.puts(string)
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
def parameters
|
55
|
+
@parameters ||= begin
|
56
|
+
escaped_pairs = options[:params].collect do |pair|
|
57
|
+
if /:/.match?(pair)
|
58
|
+
Hash[*pair.split(":", 2)].collect do |k, v|
|
59
|
+
[CGI.escape(k.strip), CGI.escape(v.strip)].join("=")
|
60
|
+
end
|
61
|
+
else
|
62
|
+
pair
|
57
63
|
end
|
58
|
-
else
|
59
|
-
pair
|
60
64
|
end
|
65
|
+
|
66
|
+
querystring = escaped_pairs * "&"
|
67
|
+
cli_params = CGI.parse(querystring)
|
68
|
+
|
69
|
+
{
|
70
|
+
"oauth_consumer_key" => options[:oauth_consumer_key],
|
71
|
+
"oauth_nonce" => options[:oauth_nonce],
|
72
|
+
"oauth_timestamp" => options[:oauth_timestamp],
|
73
|
+
"oauth_token" => options[:oauth_token],
|
74
|
+
"oauth_signature_method" => options[:oauth_signature_method],
|
75
|
+
"oauth_version" => options[:oauth_version]
|
76
|
+
}.reject { |_k, v| v.nil? || v == "" }.merge(cli_params)
|
61
77
|
end
|
78
|
+
end
|
62
79
|
|
63
|
-
|
64
|
-
|
80
|
+
def option_parser
|
81
|
+
@option_parser ||= OptionParser.new do |opts|
|
82
|
+
opts.banner = "Usage: oauth <command> [ARGS]"
|
65
83
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
"oauth_signature_method" => options[:oauth_signature_method],
|
72
|
-
"oauth_version" => options[:oauth_version]
|
73
|
-
}.reject { |_k, v| v.nil? || v == "" }.merge(cli_params)
|
84
|
+
_option_parser_defaults
|
85
|
+
_option_parser_common(opts)
|
86
|
+
_option_parser_sign_and_query(opts)
|
87
|
+
_option_parser_authorization(opts)
|
88
|
+
end
|
74
89
|
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def option_parser
|
78
|
-
@option_parser ||= OptionParser.new do |opts|
|
79
|
-
opts.banner = "Usage: oauth <command> [ARGS]"
|
80
90
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
91
|
+
def _option_parser_defaults
|
92
|
+
options[:oauth_nonce] = OAuth::Helper.generate_key
|
93
|
+
options[:oauth_signature_method] = "HMAC-SHA1"
|
94
|
+
options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
|
95
|
+
options[:oauth_version] = "1.0"
|
96
|
+
options[:method] = :post
|
97
|
+
options[:params] = []
|
98
|
+
options[:scheme] = :header
|
99
|
+
options[:version] = "1.0"
|
85
100
|
end
|
86
|
-
end
|
87
101
|
|
88
|
-
|
89
|
-
|
90
|
-
options[:oauth_signature_method] = "HMAC-SHA1"
|
91
|
-
options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
|
92
|
-
options[:oauth_version] = "1.0"
|
93
|
-
options[:method] = :post
|
94
|
-
options[:params] = []
|
95
|
-
options[:scheme] = :header
|
96
|
-
options[:version] = "1.0"
|
97
|
-
end
|
102
|
+
def _option_parser_common(opts)
|
103
|
+
## Common Options
|
98
104
|
|
99
|
-
|
100
|
-
|
105
|
+
opts.on("-B", "--body", "Use the request body for OAuth parameters.") do
|
106
|
+
options[:scheme] = :body
|
107
|
+
end
|
101
108
|
|
102
|
-
|
103
|
-
|
104
|
-
|
109
|
+
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
|
110
|
+
options[:oauth_consumer_key] = v
|
111
|
+
end
|
105
112
|
|
106
|
-
|
107
|
-
|
108
|
-
|
113
|
+
opts.on("--consumer-secret SECRET", "Specifies the consumer secret to use.") do |v|
|
114
|
+
options[:oauth_consumer_secret] = v
|
115
|
+
end
|
109
116
|
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
opts.on("-H", "--header", "Use the 'Authorization' header for OAuth parameters (default).") do
|
118
|
+
options[:scheme] = :header
|
119
|
+
end
|
113
120
|
|
114
|
-
|
115
|
-
|
116
|
-
|
121
|
+
opts.on("-Q", "--query-string", "Use the query string for OAuth parameters.") do
|
122
|
+
options[:scheme] = :query_string
|
123
|
+
end
|
117
124
|
|
118
|
-
|
119
|
-
|
125
|
+
opts.on("-O", "--options FILE", "Read options from a file") do |v|
|
126
|
+
arguments = open(v).readlines.map { |l| l.chomp.split }.flatten
|
127
|
+
options2 = parse_options(arguments)
|
128
|
+
options.merge!(options2)
|
129
|
+
end
|
120
130
|
end
|
121
131
|
|
122
|
-
opts
|
123
|
-
|
124
|
-
options2 = parse_options(arguments)
|
125
|
-
options.merge!(options2)
|
126
|
-
end
|
127
|
-
end
|
132
|
+
def _option_parser_sign_and_query(opts)
|
133
|
+
opts.separator("\n options for signing and querying")
|
128
134
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v|
|
133
|
-
options[:method] = v
|
134
|
-
end
|
135
|
+
opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v|
|
136
|
+
options[:method] = v
|
137
|
+
end
|
135
138
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
+
opts.on("--nonce NONCE", "Specifies the nonce to use.") do |v|
|
140
|
+
options[:oauth_nonce] = v
|
141
|
+
end
|
139
142
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
+
opts.on("--parameters PARAMS", "Specifies the parameters to use when signing.") do |v|
|
144
|
+
options[:params] << v
|
145
|
+
end
|
143
146
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
+
opts.on("--signature-method METHOD", "Specifies the signature method to use; defaults to HMAC-SHA1.") do |v|
|
148
|
+
options[:oauth_signature_method] = v
|
149
|
+
end
|
147
150
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
+
opts.on("--token TOKEN", "Specifies the token to use.") do |v|
|
152
|
+
options[:oauth_token] = v
|
153
|
+
end
|
151
154
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
+
opts.on("--secret SECRET", "Specifies the token secret to use.") do |v|
|
156
|
+
options[:oauth_token_secret] = v
|
157
|
+
end
|
155
158
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
+
opts.on("--timestamp TIMESTAMP", "Specifies the timestamp to use.") do |v|
|
160
|
+
options[:oauth_timestamp] = v
|
161
|
+
end
|
159
162
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
+
opts.on("--realm REALM", "Specifies the realm to use.") do |v|
|
164
|
+
options[:realm] = v
|
165
|
+
end
|
163
166
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
+
opts.on("--uri URI", "Specifies the URI to use when signing.") do |v|
|
168
|
+
options[:uri] = v
|
169
|
+
end
|
167
170
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
+
opts.on("--version [VERSION]", "Specifies the OAuth version to use.") do |v|
|
172
|
+
options[:oauth_version] = v
|
173
|
+
end
|
171
174
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
+
opts.on("--no-version", "Omit oauth_version.") do
|
176
|
+
options[:oauth_version] = nil
|
177
|
+
end
|
175
178
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
179
|
+
opts.on("--xmpp", "Generate XMPP stanzas.") do
|
180
|
+
options[:xmpp] = true
|
181
|
+
options[:method] ||= "iq"
|
182
|
+
end
|
180
183
|
|
181
|
-
|
182
|
-
|
184
|
+
opts.on("-v", "--verbose", "Be verbose.") do
|
185
|
+
options[:verbose] = true
|
186
|
+
end
|
183
187
|
end
|
184
|
-
end
|
185
188
|
|
186
|
-
|
187
|
-
|
189
|
+
def _option_parser_authorization(opts)
|
190
|
+
opts.separator("\n options for authorization")
|
188
191
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
+
opts.on("--access-token-url URL", "Specifies the access token URL.") do |v|
|
193
|
+
options[:access_token_url] = v
|
194
|
+
end
|
192
195
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
+
opts.on("--authorize-url URL", "Specifies the authorization URL.") do |v|
|
197
|
+
options[:authorize_url] = v
|
198
|
+
end
|
196
199
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
+
opts.on("--callback-url URL", "Specifies a callback URL.") do |v|
|
201
|
+
options[:oauth_callback] = v
|
202
|
+
end
|
200
203
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
+
opts.on("--request-token-url URL", "Specifies the request token URL.") do |v|
|
205
|
+
options[:request_token_url] = v
|
206
|
+
end
|
204
207
|
|
205
|
-
|
206
|
-
|
208
|
+
opts.on("--scope SCOPE", "Specifies the scope (Google-specific).") do |v|
|
209
|
+
options[:scope] = v
|
210
|
+
end
|
207
211
|
end
|
208
212
|
end
|
209
213
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OAuth
|
4
|
+
class CLI
|
5
|
+
class HelpCommand < BaseCommand
|
6
|
+
def run
|
7
|
+
puts <<-EOT
|
5
8
|
Usage: oauth COMMAND [ARGS]
|
6
9
|
|
7
10
|
Available oauth commands are:
|
@@ -16,7 +19,8 @@ class OAuth::CLI
|
|
16
19
|
Tip: All commands can be run without args for specific help.
|
17
20
|
|
18
21
|
|
19
|
-
|
22
|
+
EOT
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -1,25 +1,34 @@
|
|
1
|
-
|
2
|
-
class QueryCommand < BaseCommand
|
3
|
-
extend OAuth::Helper
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module OAuth
|
4
|
+
class CLI
|
5
|
+
class QueryCommand < BaseCommand
|
6
|
+
extend OAuth::Helper
|
7
|
+
|
8
|
+
def required_options
|
9
|
+
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
def _run
|
13
|
+
consumer = OAuth::Consumer.new(options[:oauth_consumer_key], options[:oauth_consumer_secret],
|
14
|
+
scheme: options[:scheme])
|
11
15
|
|
12
|
-
|
16
|
+
access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret])
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
# append params to the URL
|
19
|
+
uri = URI.parse(options[:uri])
|
20
|
+
params = parameters.map do |k, v|
|
21
|
+
Array(v).map do |v2|
|
22
|
+
"#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}"
|
23
|
+
end * "&"
|
24
|
+
end
|
25
|
+
uri.query = [uri.query, *params].compact * "&"
|
26
|
+
puts uri.to_s
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
|
28
|
+
response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
|
29
|
+
puts "#{response.code} #{response.message}"
|
30
|
+
puts response.body
|
31
|
+
end
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
@@ -1,68 +1,73 @@
|
|
1
|
-
|
2
|
-
class SignCommand < BaseCommand
|
3
|
-
def required_options
|
4
|
-
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module OAuth
|
4
|
+
class CLI
|
5
|
+
class SignCommand < BaseCommand
|
6
|
+
def required_options
|
7
|
+
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
8
|
+
end
|
12
9
|
|
13
|
-
|
10
|
+
def _run
|
11
|
+
request = OAuth::RequestProxy.proxy \
|
12
|
+
"method" => options[:method],
|
13
|
+
"uri" => options[:uri],
|
14
|
+
"parameters" => parameters
|
14
15
|
|
15
|
-
|
16
|
-
consumer_secret: options[:oauth_consumer_secret],
|
17
|
-
token_secret: options[:oauth_token_secret]
|
16
|
+
puts_verbose_parameters(request) if verbose?
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
puts request.oauth_signature
|
23
|
-
end
|
24
|
-
end
|
18
|
+
request.sign! \
|
19
|
+
consumer_secret: options[:oauth_consumer_secret],
|
20
|
+
token_secret: options[:oauth_token_secret]
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
if verbose?
|
23
|
+
puts_verbose_request(request)
|
24
|
+
else
|
25
|
+
puts request.oauth_signature
|
26
|
+
end
|
30
27
|
end
|
31
|
-
puts
|
32
28
|
|
33
|
-
|
34
|
-
puts "
|
35
|
-
request.
|
36
|
-
puts "
|
29
|
+
def puts_verbose_parameters(request)
|
30
|
+
puts "OAuth parameters:"
|
31
|
+
request.oauth_parameters.each do |k, v|
|
32
|
+
puts " #{[k, v].join(": ")}"
|
37
33
|
end
|
38
34
|
puts
|
35
|
+
|
36
|
+
if request.non_oauth_parameters.any?
|
37
|
+
puts "Parameters:"
|
38
|
+
request.non_oauth_parameters.each do |k, v|
|
39
|
+
puts " #{[k, v].join(": ")}"
|
40
|
+
end
|
41
|
+
puts
|
42
|
+
end
|
39
43
|
end
|
40
|
-
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
def puts_verbose_request(request)
|
46
|
+
puts "Method: #{request.method}"
|
47
|
+
puts "URI: #{request.uri}"
|
48
|
+
unless options[:xmpp]
|
49
|
+
puts "Normalized params: #{request.normalized_parameters}"
|
50
|
+
end
|
51
|
+
puts "Signature base string: #{request.signature_base_string}"
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
if xmpp?
|
54
|
+
puts
|
55
|
+
puts "XMPP Stanza:"
|
56
|
+
puts xmpp_output(request)
|
57
|
+
puts
|
58
|
+
puts "Note: You may want to use bare JIDs in your URI."
|
59
|
+
puts
|
60
|
+
else
|
61
|
+
puts "OAuth Request URI: #{request.signed_uri}"
|
62
|
+
puts "Request URI: #{request.signed_uri(with_oauth: false)}"
|
63
|
+
puts "Authorization header: #{request.oauth_header(realm: options[:realm])}"
|
64
|
+
end
|
65
|
+
puts "Signature: #{request.oauth_signature}"
|
66
|
+
puts "Escaped signature: #{OAuth::Helper.escape(request.oauth_signature)}"
|
59
67
|
end
|
60
|
-
puts "Signature: #{request.oauth_signature}"
|
61
|
-
puts "Escaped signature: #{OAuth::Helper.escape(request.oauth_signature)}"
|
62
|
-
end
|
63
68
|
|
64
|
-
|
65
|
-
|
69
|
+
def xmpp_output(request)
|
70
|
+
<<-EOS
|
66
71
|
<oauth xmlns='urn:xmpp:oauth:0'>
|
67
72
|
<oauth_consumer_key>#{request.oauth_consumer_key}</oauth_consumer_key>
|
68
73
|
<oauth_token>#{request.oauth_token}</oauth_token>
|
@@ -72,7 +77,8 @@ class OAuth::CLI
|
|
72
77
|
<oauth_nonce>#{request.oauth_nonce}</oauth_nonce>
|
73
78
|
<oauth_version>#{request.oauth_version}</oauth_version>
|
74
79
|
</oauth>
|
75
|
-
|
80
|
+
EOS
|
81
|
+
end
|
76
82
|
end
|
77
83
|
end
|
78
84
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OAuth
|
4
|
+
class CLI
|
5
|
+
class VersionCommand < BaseCommand
|
6
|
+
def run
|
7
|
+
puts "OAuth Gem #{OAuth::Version::VERSION}"
|
8
|
+
end
|
5
9
|
end
|
6
10
|
end
|
7
11
|
end
|
data/lib/oauth/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if defined? ActionDispatch
|
2
4
|
require "oauth/request_proxy/rack_request"
|
3
5
|
require "oauth/request_proxy/action_dispatch_request"
|
@@ -44,7 +46,8 @@ module ActionController
|
|
44
46
|
def apply_oauth!
|
45
47
|
return unless ActionController::TestRequest.use_oauth? && @oauth_options
|
46
48
|
|
47
|
-
@oauth_helper = OAuth::Client::Helper.new(self,
|
49
|
+
@oauth_helper = OAuth::Client::Helper.new(self,
|
50
|
+
@oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri)))
|
48
51
|
@oauth_helper.amend_user_agent_header(env)
|
49
52
|
|
50
53
|
send("set_oauth_#{@oauth_options[:scheme]}")
|
data/lib/oauth/client/em_http.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "em-http"
|
2
4
|
require "oauth/helper"
|
3
5
|
require "oauth/request_proxy/em_http_request"
|
@@ -81,7 +83,7 @@ module EventMachine
|
|
81
83
|
query.map { |k, v| encode_param(k, v) }.join("&")
|
82
84
|
else
|
83
85
|
query.to_s
|
84
|
-
|
86
|
+
end
|
85
87
|
unless uri_query.to_s.empty?
|
86
88
|
combined_query = [combined_query, uri_query].reject(&:empty?).join("&")
|
87
89
|
end
|