oauth 0.5.13 → 1.0.0

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