mojodna-oauth 0.3.4.1 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -1
- data/lib/oauth/cli.rb +62 -38
- data/lib/oauth/consumer.rb +12 -2
- data/lib/oauth/request_proxy/action_controller_request.rb +1 -0
- data/lib/oauth/version.rb +1 -1
- data/oauth.gemspec +2 -2
- data/test/test_consumer.rb +3 -0
- data/website/index.html +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
== 0.3.5
|
1
|
+
== 0.3.5 2009-06-03
|
2
2
|
|
3
3
|
* `query` CLI command to access protected resources (Seth)
|
4
4
|
* Added -H, -Q CLI options for specifying the authorization scheme (Seth)
|
5
5
|
* Added -O CLI option for specifying a file containing options (Seth)
|
6
6
|
* Support streamable body contents for large request bodies (Seth Cousins)
|
7
7
|
* Support for OAuth 1.0a (Seth)
|
8
|
+
* Added proxy support to OAuth::Consumer (Marshall Huss)
|
9
|
+
* Added --scope CLI option for Google's 'scope' parameter (Seth)
|
8
10
|
|
9
11
|
== 0.3.4 2009-05-06
|
10
12
|
|
data/lib/oauth/cli.rb
CHANGED
@@ -7,7 +7,8 @@ module OAuth
|
|
7
7
|
"authorize" => "Obtain an access token and secret for a user",
|
8
8
|
"debug" => "Verbosely generate an OAuth signature",
|
9
9
|
"query" => "Query a protected resource",
|
10
|
-
"sign" => "Generate an OAuth signature"
|
10
|
+
"sign" => "Generate an OAuth signature",
|
11
|
+
"version" => "Display the current version of the library"
|
11
12
|
}
|
12
13
|
|
13
14
|
attr_reader :command
|
@@ -42,47 +43,54 @@ module OAuth
|
|
42
43
|
case command
|
43
44
|
# TODO move command logic elsewhere
|
44
45
|
when "authorize"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
46
|
+
begin
|
47
|
+
consumer = OAuth::Consumer.new \
|
48
|
+
options[:oauth_consumer_key],
|
49
|
+
options[:oauth_consumer_secret],
|
50
|
+
:access_token_url => options[:access_token_url],
|
51
|
+
:authorize_url => options[:authorize_url],
|
52
|
+
:request_token_url => options[:request_token_url],
|
53
|
+
:scheme => options[:scheme]
|
54
|
+
|
55
|
+
# parameters for OAuth 1.0a
|
56
|
+
oauth_verifier = nil
|
57
|
+
|
58
|
+
# get a request token
|
59
|
+
request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { :scope => options[:scope] })
|
60
|
+
|
61
|
+
if request_token.callback_confirmed?
|
62
|
+
stdout.puts "Server appears to support OAuth 1.0a; enabling support."
|
63
|
+
options[:version] = "1.0a"
|
64
|
+
end
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
+
stdout.puts "Please visit this url to authorize:"
|
67
|
+
stdout.puts request_token.authorize_url
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
if options[:version] == "1.0a"
|
70
|
+
stdout.puts "Please enter the verification code provided by the SP (oauth_verifier):"
|
71
|
+
oauth_verifier = stdin.gets.chomp
|
72
|
+
else
|
73
|
+
stdout.puts "Press return to continue..."
|
74
|
+
stdin.gets
|
75
|
+
end
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
begin
|
78
|
+
# get an access token
|
79
|
+
access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
stdout.puts "Response:"
|
82
|
+
access_token.params.each do |k,v|
|
83
|
+
stdout.puts " #{k}: #{v}" unless k.is_a?(Symbol)
|
84
|
+
end
|
85
|
+
rescue OAuth::Unauthorized => e
|
86
|
+
stderr.puts "A problem occurred while attempting to obtain an access token:"
|
87
|
+
stderr.puts e
|
88
|
+
stderr.puts e.request.body
|
82
89
|
end
|
83
90
|
rescue OAuth::Unauthorized => e
|
84
|
-
stderr.puts "A problem occurred while attempting to
|
91
|
+
stderr.puts "A problem occurred while attempting to authorize:"
|
85
92
|
stderr.puts e
|
93
|
+
stderr.puts e.request.body
|
86
94
|
end
|
87
95
|
when "query"
|
88
96
|
consumer = OAuth::Consumer.new \
|
@@ -156,6 +164,8 @@ module OAuth
|
|
156
164
|
else
|
157
165
|
stdout.puts request.oauth_signature
|
158
166
|
end
|
167
|
+
when "version"
|
168
|
+
puts "OAuth for Ruby #{OAuth::VERSION}"
|
159
169
|
end
|
160
170
|
else
|
161
171
|
usage
|
@@ -169,7 +179,7 @@ module OAuth
|
|
169
179
|
parse_options(arguments[0..-1])
|
170
180
|
end
|
171
181
|
|
172
|
-
def option_parser(arguments)
|
182
|
+
def option_parser(arguments = "")
|
173
183
|
# TODO add realm parameter
|
174
184
|
# TODO add user-agent parameter
|
175
185
|
option_parser = OptionParser.new do |opts|
|
@@ -208,6 +218,8 @@ module OAuth
|
|
208
218
|
|
209
219
|
## Options for signing and making requests
|
210
220
|
|
221
|
+
opts.separator("\n options for signing and querying")
|
222
|
+
|
211
223
|
opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v|
|
212
224
|
options[:method] = v
|
213
225
|
end
|
@@ -244,8 +256,12 @@ module OAuth
|
|
244
256
|
options[:uri] = v
|
245
257
|
end
|
246
258
|
|
247
|
-
opts.on("--version VERSION", "Specifies the OAuth version to use.") do |v|
|
248
|
-
|
259
|
+
opts.on(:OPTIONAL, "--version VERSION", "Specifies the OAuth version to use.") do |v|
|
260
|
+
if v
|
261
|
+
options[:oauth_version] = v
|
262
|
+
else
|
263
|
+
@command = "version"
|
264
|
+
end
|
249
265
|
end
|
250
266
|
|
251
267
|
opts.on("--no-version", "Omit oauth_version.") do
|
@@ -263,6 +279,8 @@ module OAuth
|
|
263
279
|
|
264
280
|
## Options for authorization
|
265
281
|
|
282
|
+
opts.separator("\n options for authorization")
|
283
|
+
|
266
284
|
opts.on("--access-token-url URL", "Specifies the access token URL.") do |v|
|
267
285
|
options[:access_token_url] = v
|
268
286
|
end
|
@@ -278,6 +296,10 @@ module OAuth
|
|
278
296
|
opts.on("--request-token-url URL", "Specifies the request token URL.") do |v|
|
279
297
|
options[:request_token_url] = v
|
280
298
|
end
|
299
|
+
|
300
|
+
opts.on("--scope SCOPE", "Specifies the scope (Google-specific).") do |v|
|
301
|
+
options[:scope] = v
|
302
|
+
end
|
281
303
|
end
|
282
304
|
end
|
283
305
|
|
@@ -316,6 +338,8 @@ module OAuth
|
|
316
338
|
options[:oauth_consumer_key] && options[:oauth_consumer_secret] &&
|
317
339
|
options[:access_token_url] && options[:authorize_url] &&
|
318
340
|
options[:request_token_url]
|
341
|
+
when "version"
|
342
|
+
true
|
319
343
|
else
|
320
344
|
options[:oauth_consumer_key] && options[:oauth_consumer_secret] &&
|
321
345
|
options[:method] && options[:uri]
|
data/lib/oauth/consumer.rb
CHANGED
@@ -25,6 +25,7 @@ module OAuth
|
|
25
25
|
:authorize_path => '/oauth/authorize',
|
26
26
|
:access_token_path => '/oauth/access_token',
|
27
27
|
|
28
|
+
:proxy => nil,
|
28
29
|
# How do we send the oauth values to the server see
|
29
30
|
# http://oauth.net/core/1.0/#consumer_req_param for more info
|
30
31
|
#
|
@@ -254,6 +255,10 @@ module OAuth
|
|
254
255
|
@options.has_key?(:access_token_url)
|
255
256
|
end
|
256
257
|
|
258
|
+
def proxy
|
259
|
+
@options[:proxy]
|
260
|
+
end
|
261
|
+
|
257
262
|
protected
|
258
263
|
|
259
264
|
# Instantiates the http object
|
@@ -264,7 +269,12 @@ module OAuth
|
|
264
269
|
our_uri = URI.parse(_url)
|
265
270
|
end
|
266
271
|
|
267
|
-
|
272
|
+
if proxy.nil?
|
273
|
+
http_object = Net::HTTP.new(our_uri.host, our_uri.port)
|
274
|
+
else
|
275
|
+
proxy_uri = proxy.is_a?(URI) ? proxy : URI.parse(proxy)
|
276
|
+
http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
277
|
+
end
|
268
278
|
|
269
279
|
http_object.use_ssl = (our_uri.scheme == 'https')
|
270
280
|
|
@@ -284,7 +294,7 @@ module OAuth
|
|
284
294
|
http_method = http_method.to_sym
|
285
295
|
|
286
296
|
if [:post, :put].include?(http_method)
|
287
|
-
data = arguments.shift
|
297
|
+
data = (arguments.shift || {}).reject { |k,v| v.nil? }
|
288
298
|
end
|
289
299
|
|
290
300
|
headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
|
data/lib/oauth/version.rb
CHANGED
data/oauth.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{oauth}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-06-03}
|
10
10
|
s.default_executable = %q{oauth}
|
11
11
|
s.description = %q{OAuth Core Ruby implementation}
|
12
12
|
s.email = %q{oauth-ruby@googlegroups.com}
|
data/test/test_consumer.rb
CHANGED
@@ -13,6 +13,7 @@ class ConsumerTest < Test::Unit::TestCase
|
|
13
13
|
'consumer_key_86cad9', '5888bf0345e5d237',
|
14
14
|
{
|
15
15
|
:site=>"http://blabla.bla",
|
16
|
+
:proxy=>"http://user:password@proxy.bla:8080",
|
16
17
|
:request_token_path=>"/oauth/example/request_token.php",
|
17
18
|
:access_token_path=>"/oauth/example/access_token.php",
|
18
19
|
:authorize_path=>"/oauth/example/authorize.php",
|
@@ -31,6 +32,7 @@ class ConsumerTest < Test::Unit::TestCase
|
|
31
32
|
assert_equal "consumer_key_86cad9",@consumer.key
|
32
33
|
assert_equal "5888bf0345e5d237",@consumer.secret
|
33
34
|
assert_equal "http://blabla.bla",@consumer.site
|
35
|
+
assert_equal "http://user:password@proxy.bla:8080",@consumer.proxy
|
34
36
|
assert_equal "/oauth/example/request_token.php",@consumer.request_token_path
|
35
37
|
assert_equal "/oauth/example/access_token.php",@consumer.access_token_path
|
36
38
|
assert_equal "http://blabla.bla/oauth/example/request_token.php",@consumer.request_token_url
|
@@ -50,6 +52,7 @@ class ConsumerTest < Test::Unit::TestCase
|
|
50
52
|
assert_equal "key",@consumer.key
|
51
53
|
assert_equal "secret",@consumer.secret
|
52
54
|
assert_equal "http://twitter.com",@consumer.site
|
55
|
+
assert_nil @consumer.proxy
|
53
56
|
assert_equal "/oauth/request_token",@consumer.request_token_path
|
54
57
|
assert_equal "/oauth/access_token",@consumer.access_token_path
|
55
58
|
assert_equal "http://twitter.com/oauth/request_token",@consumer.request_token_url
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Ruby OAuth GEM</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oauth"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.
|
36
|
+
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.5</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
<p>This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.</p>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojodna-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2009-
|
18
|
+
date: 2009-06-03 00:00:00 -07:00
|
19
19
|
default_executable: oauth
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|