oauth 0.5.12 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -3
  3. data/README.md +56 -46
  4. data/SECURITY.md +0 -2
  5. data/bin/oauth +8 -4
  6. data/lib/oauth/cli/authorize_command.rb +58 -54
  7. data/lib/oauth/cli/base_command.rb +163 -159
  8. data/lib/oauth/cli/help_command.rb +9 -5
  9. data/lib/oauth/cli/query_command.rb +26 -17
  10. data/lib/oauth/cli/sign_command.rb +58 -52
  11. data/lib/oauth/cli/version_command.rb +8 -4
  12. data/lib/oauth/cli.rb +2 -0
  13. data/lib/oauth/client/action_controller_request.rb +4 -1
  14. data/lib/oauth/client/em_http.rb +3 -1
  15. data/lib/oauth/client/helper.rb +76 -72
  16. data/lib/oauth/client/net_http.rb +111 -104
  17. data/lib/oauth/client.rb +2 -0
  18. data/lib/oauth/consumer.rb +50 -32
  19. data/lib/oauth/errors/error.rb +2 -0
  20. data/lib/oauth/errors/problem.rb +3 -0
  21. data/lib/oauth/errors/unauthorized.rb +4 -0
  22. data/lib/oauth/errors.rb +2 -0
  23. data/lib/oauth/helper.rb +9 -5
  24. data/lib/oauth/oauth.rb +4 -2
  25. data/lib/oauth/oauth_test_helper.rb +2 -0
  26. data/lib/oauth/request_proxy/base.rb +4 -4
  27. data/lib/oauth/request_proxy/mock_request.rb +1 -1
  28. data/lib/oauth/request_proxy/net_http.rb +8 -8
  29. data/lib/oauth/request_proxy/rest_client_request.rb +4 -3
  30. data/lib/oauth/request_proxy.rb +4 -1
  31. data/lib/oauth/server.rb +8 -4
  32. data/lib/oauth/signature/base.rb +73 -65
  33. data/lib/oauth/signature/hmac/sha1.rb +15 -9
  34. data/lib/oauth/signature/hmac/sha256.rb +15 -9
  35. data/lib/oauth/signature/plaintext.rb +18 -20
  36. data/lib/oauth/signature/rsa/sha1.rb +46 -38
  37. data/lib/oauth/signature.rb +3 -0
  38. data/lib/oauth/token.rb +2 -0
  39. data/lib/oauth/tokens/access_token.rb +2 -0
  40. data/lib/oauth/tokens/consumer_token.rb +2 -0
  41. data/lib/oauth/tokens/request_token.rb +5 -2
  42. data/lib/oauth/tokens/server_token.rb +2 -0
  43. data/lib/oauth/tokens/token.rb +2 -0
  44. data/lib/oauth/version.rb +5 -1
  45. data/lib/oauth.rb +8 -2
  46. metadata +29 -31
@@ -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,73 @@
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
+ unless options[:xmpp]
49
+ puts "Normalized params: #{request.normalized_parameters}"
50
+ end
51
+ puts "Signature base string: #{request.signature_base_string}"
47
52
 
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])}"
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
- def xmpp_output(request)
65
- <<-EOS
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
- EOS
80
+ EOS
81
+ end
76
82
  end
77
83
  end
78
84
  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,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
- end
86
+ end
85
87
  unless uri_query.to_s.empty?
86
88
  combined_query = [combined_query, uri_query].reject(&:empty?).join("&")
87
89
  end