oauth 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oauth might be problematic. Click here for more details.

data/History.txt CHANGED
@@ -1,7 +1,16 @@
1
+ == 0.3.6 2009-09-14
2
+
3
+ * Added -B CLI option to use the :body authentication scheme (Seth)
4
+ * Respect `--method` in `authorize` CLI command (Seth)
5
+ * Support POST and PUT with raw bodies (Yu-Shan Fung et al)
6
+ * Test clean-up (Xavier Shay, Hannes Tydén)
7
+ * Added :ca_file consumer option to allow consumer specific certificate
8
+ override. (Pelle)
9
+
1
10
  == 0.3.5 2009-06-03
2
11
 
3
12
  * `query` CLI command to access protected resources (Seth)
4
- * Added -H, -Q CLI options for specifying the authorization scheme (Seth)
13
+ * Added -H, -Q CLI options for specifying the authentication scheme (Seth)
5
14
  * Added -O CLI option for specifying a file containing options (Seth)
6
15
  * Support streamable body contents for large request bodies (Seth Cousins)
7
16
  * Support for OAuth 1.0a (Seth)
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen hoe].each { |f| require f }
2
2
  $LOAD_PATH << File.dirname(__FILE__) + '/lib'
3
3
  require 'oauth'
4
4
  require 'oauth/version'
data/lib/oauth/cli.rb CHANGED
@@ -50,13 +50,14 @@ module OAuth
50
50
  :access_token_url => options[:access_token_url],
51
51
  :authorize_url => options[:authorize_url],
52
52
  :request_token_url => options[:request_token_url],
53
- :scheme => options[:scheme]
53
+ :scheme => options[:scheme],
54
+ :http_method => options[:method].to_s.downcase.to_sym
54
55
 
55
56
  # parameters for OAuth 1.0a
56
57
  oauth_verifier = nil
57
58
 
58
59
  # get a request token
59
- request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { :scope => options[:scope] })
60
+ request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { "scope" => options[:scope] })
60
61
 
61
62
  if request_token.callback_confirmed?
62
63
  stdout.puts "Server appears to support OAuth 1.0a; enabling support."
@@ -100,7 +101,13 @@ module OAuth
100
101
 
101
102
  access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret])
102
103
 
103
- response = access_token.request(options[:method].downcase.to_sym, options[:uri])
104
+ # append params to the URL
105
+ uri = URI.parse(options[:uri])
106
+ params = prepare_parameters.map { |k,v| v.map { |v2| "#{URI.encode(k)}=#{URI.encode(v2)}" } * "&" }
107
+ uri.query = [uri.query, *params].reject { |x| x.nil? } * "&"
108
+ p uri.to_s
109
+
110
+ response = access_token.request(options[:method].downcase.to_sym, uri.to_s)
104
111
  puts "#{response.code} #{response.message}"
105
112
  puts response.body
106
113
  when "sign"
@@ -190,12 +197,17 @@ module OAuth
190
197
  options[:oauth_signature_method] = "HMAC-SHA1"
191
198
  options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
192
199
  options[:oauth_version] = "1.0"
200
+ options[:method] = :post
193
201
  options[:params] = []
194
202
  options[:scheme] = :header
195
203
  options[:version] = "1.0"
196
204
 
197
205
  ## Common Options
198
206
 
207
+ opts.on("-B", "--body", "Use the request body for OAuth parameters.") do
208
+ options[:scheme] = :body
209
+ end
210
+
199
211
  opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
200
212
  options[:oauth_consumer_key] = v
201
213
  end
@@ -39,6 +39,9 @@ module OAuth
39
39
  # Default http method used for OAuth Token Requests (defaults to :post)
40
40
  :http_method => :post,
41
41
 
42
+ # Add a custom ca_file for consumer
43
+ # :ca_file => '/etc/certs.pem'
44
+
42
45
  :oauth_version => "1.0"
43
46
  }
44
47
 
@@ -278,8 +281,8 @@ module OAuth
278
281
 
279
282
  http_object.use_ssl = (our_uri.scheme == 'https')
280
283
 
281
- if CA_FILE
282
- http_object.ca_file = CA_FILE
284
+ if @options[:ca_file] || CA_FILE
285
+ http_object.ca_file = @options[:ca_file] || CA_FILE
283
286
  http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER
284
287
  http_object.verify_depth = 5
285
288
  else
@@ -294,7 +297,8 @@ module OAuth
294
297
  http_method = http_method.to_sym
295
298
 
296
299
  if [:post, :put].include?(http_method)
297
- data = (arguments.shift || {}).reject { |k,v| v.nil? }
300
+ data = arguments.shift
301
+ data.reject! { |k,v| v.nil? } if data.is_a?(Hash)
298
302
  end
299
303
 
300
304
  headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
@@ -1,7 +1,6 @@
1
1
  require 'active_support'
2
2
  require 'action_controller'
3
3
  require 'action_controller/request'
4
- require 'oauth/request_proxy/base'
5
4
  require 'uri'
6
5
 
7
6
  module OAuth::RequestProxy
data/lib/oauth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OAuth #:nodoc:
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
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"
5
+ s.version = "0.3.6"
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-06-03}
9
+ s.date = %q{2009-09-14}
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}
@@ -1,6 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/token'
3
- require 'oauth/consumer'
4
2
 
5
3
  class TestAccessToken < Test::Unit::TestCase
6
4
  def setup
@@ -1,10 +1,10 @@
1
+ gem 'actionpack','2.2.2'
1
2
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/request_proxy/action_controller_request.rb'
3
- require 'action_controller'
3
+
4
+ require 'oauth/request_proxy/action_controller_request'
4
5
  require 'action_controller/test_process'
5
6
 
6
7
  class ActionControllerRequestProxyTest < Test::Unit::TestCase
7
-
8
8
  def request_proxy(request_method = :get, uri_params = {}, body_params = {})
9
9
  request = ActionController::TestRequest.new
10
10
 
@@ -15,11 +15,13 @@ class ActionControllerRequestProxyTest < Test::Unit::TestCase
15
15
  request.env['REQUEST_METHOD'] = 'PUT'
16
16
  end
17
17
 
18
+ request.env['REQUEST_URI'] = '/'
18
19
  request.env['RAW_POST_DATA'] = body_params.to_query
20
+ request.env['QUERY_STRING'] = body_params.to_query
19
21
  request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
20
22
 
21
23
  yield request if block_given?
22
- OAuth::RequestProxy.proxy(request, :parameters=>uri_params)
24
+ OAuth::RequestProxy.proxy(request, :parameters => uri_params)
23
25
  end
24
26
 
25
27
  def test_that_proxy_simple_get_request_works_with_query_params
@@ -46,7 +48,7 @@ class ActionControllerRequestProxyTest < Test::Unit::TestCase
46
48
  assert_equal 'PUT', request_proxy.method
47
49
  end
48
50
 
49
- def test_that_proxy_simple_put_request_works_with_post_params
51
+ def test_that_proxy_simple_get_request_works_with_post_params
50
52
  request_proxy = request_proxy(:get, {}, {'key'=>'value'})
51
53
 
52
54
  expected_parameters = []
@@ -70,7 +72,7 @@ class ActionControllerRequestProxyTest < Test::Unit::TestCase
70
72
  assert_equal 'PUT', request_proxy.method
71
73
  end
72
74
 
73
- def test_that_proxy_simple_put_request_works_with_mixed_params
75
+ def test_that_proxy_simple_get_request_works_with_mixed_params
74
76
  request_proxy = request_proxy(:get, {'key'=>'value'}, {'key2'=>'value2'})
75
77
 
76
78
  expected_parameters = [["key", "value"]]
@@ -1,8 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
- require 'oauth/consumer'
3
- require 'oauth/signature/rsa/sha1'
4
- require 'stringio'
5
2
 
3
+ require 'stringio'
6
4
 
7
5
  # This performs testing against Andy Smith's test server http://term.ie/oauth/example/
8
6
  # Thanks Andy.
data/test/test_helper.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/oauth'
2
+
3
+ $LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
4
+ require 'oauth'
5
+
6
+ # require File.dirname(__FILE__) + '/../lib/oauth'
3
7
 
4
8
  begin
5
9
  # load redgreen unless running from within TextMate (in which case ANSI
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/signature/hmac/sha1'
3
2
 
4
3
  class TestSignatureHmacSha1 < Test::Unit::TestCase
5
4
  def test_that_hmac_sha1_implements_hmac_sha1
@@ -1,6 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/client/net_http'
3
- require 'oauth/version'
4
2
 
5
3
  class NetHTTPClientTest < Test::Unit::TestCase
6
4
 
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/request_proxy/net_http'
3
2
 
4
3
  class NetHTTPRequestProxyTest < Test::Unit::TestCase
5
4
 
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/helper'
3
2
 
4
3
  class TestOAuthHelper < Test::Unit::TestCase
5
4
 
@@ -1,6 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/token'
3
- require 'oauth/consumer'
4
2
 
5
3
  class StubbedToken < OAuth::RequestToken
6
4
  define_method :build_authorize_url_promoted do |root_domain, params|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pelle Braendgaard
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2009-06-03 00:00:00 -07:00
17
+ date: 2009-09-14 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 1.2.3
38
+ version: 1.5.2
39
39
  version:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: actionpack
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.0
68
+ version: 2.3.3
69
69
  version:
70
70
  description: OAuth Core Ruby implementation
71
71
  email: oauth-ruby@googlegroups.com
@@ -77,7 +77,6 @@ extra_rdoc_files:
77
77
  - History.txt
78
78
  - License.txt
79
79
  - Manifest.txt
80
- - README.rdoc
81
80
  - website/index.txt
82
81
  files:
83
82
  - History.txt
@@ -171,7 +170,7 @@ licenses: []
171
170
  post_install_message:
172
171
  rdoc_options:
173
172
  - --main
174
- - README.rdoc
173
+ - README.txt
175
174
  require_paths:
176
175
  - lib
177
176
  required_ruby_version: !ruby/object:Gem::Requirement