oauth 0.5.8 → 0.6.0

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