oauth 0.4.0 → 0.4.1

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 CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.4.1 2010-06-16
2
+
3
+ * Added support for using OAuth with proxies (Marsh Gardiner)
4
+ * Rails 3 Compatibility fixes (Pelle Braendgaard)
5
+ * Fixed load errors on tests for missing (non-required) libraries
6
+
1
7
  == 0.4.0 2010-04-22
2
8
 
3
9
  * Added computation of oauth_body_hash as per OAuth Request Body Hash 1.0
@@ -10,8 +10,6 @@ See the OAuth specs http://oauth.net/core/1.0/
10
10
 
11
11
  sudo gem install oauth
12
12
 
13
- You can also install it from the oauth rubyforge project http://rubyforge.org/projects/oauth/.
14
-
15
13
  The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
16
14
 
17
15
  == The basics
@@ -48,28 +46,14 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
48
46
  hydra.run
49
47
  @response = req.response
50
48
 
51
- For more detailed instructions I have written this OAuth Client Tutorial http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider .
52
-
53
- If you wish to use em-http-request, you can find an example "in the official em-http-request repository":http://github.com/igrigorik/em-http-request/blob/master/examples/oauth-tweet.rb
54
-
55
- Finally be sure to check out the OAuth RDoc Manual http://oauth.rubyforge.org/rdoc/ .
56
-
57
- == Documentation Wiki
58
-
59
- There is some documentation on the Google Code project for the "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ :
60
49
 
61
- * RequestToken http://code.google.com/p/oauth-plugin/wiki/RequestToken
62
- * AccessToken http://code.google.com/p/oauth-plugin/wiki/AccessToken
63
-
64
- == Forum
65
-
66
- http://groups.google.com/group/oauth-ruby
50
+ == More Information
67
51
 
52
+ * RDoc: http://rdoc.info/projects/oauth/oauth-ruby/
53
+ * Mailing List/Google Group: http://groups.google.com/group/oauth-ruby
68
54
 
69
55
  == How to submit patches
70
56
 
71
- Read the "8 steps for fixing other people's code" http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/.
72
-
73
57
  The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
74
58
 
75
59
  To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
@@ -83,5 +67,4 @@ This code is free to use under the terms of the MIT license.
83
67
  OAuth Ruby has been created and maintained by a large number of talented individuals.
84
68
  The current maintainer is Aaron Quint (quirkey).
85
69
 
86
- Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
87
-
70
+ Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
2
 
3
3
  module OAuth
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
6
6
 
7
7
  require 'oauth/oauth'
@@ -11,7 +11,7 @@ class Net::HTTPRequest
11
11
  # this may add a header, additional query string parameters, or additional POST body parameters.
12
12
  # The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
13
13
  # header.
14
- #
14
+ #
15
15
  # * http - Configured Net::HTTP instance
16
16
  # * consumer - OAuth::Consumer instance
17
17
  # * token - OAuth::Token instance
@@ -35,13 +35,13 @@ class Net::HTTPRequest
35
35
  # on the <tt>options[:scheme]</tt> being used so this must match what will be used for the request
36
36
  # itself. The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
37
37
  # header.
38
- #
38
+ #
39
39
  # * http - Configured Net::HTTP instance
40
40
  # * consumer - OAuth::Consumer instance
41
41
  # * token - OAuth::Token instance
42
42
  # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
43
43
  # +signature_method+, +nonce+, +timestamp+)
44
- #
44
+ #
45
45
  # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1],
46
46
  # {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html]
47
47
  def signature_base_string(http, consumer = nil, token = nil, options = {})
@@ -54,7 +54,7 @@ class Net::HTTPRequest
54
54
  private
55
55
 
56
56
  def oauth_helper_options(http, consumer, token, options)
57
- { :request_uri => oauth_full_request_uri(http),
57
+ { :request_uri => oauth_full_request_uri(http,options),
58
58
  :consumer => consumer,
59
59
  :token => token,
60
60
  :scheme => 'header',
@@ -63,17 +63,30 @@ private
63
63
  :timestamp => nil }.merge(options)
64
64
  end
65
65
 
66
- def oauth_full_request_uri(http)
66
+ def oauth_full_request_uri(http,options)
67
67
  uri = URI.parse(self.path)
68
68
  uri.host = http.address
69
69
  uri.port = http.port
70
70
 
71
+ if options[:request_endpoint] and options[:site]
72
+ hostval = options[:site]
73
+ if hostval.include?("http://")
74
+ hostval["http://"] = ""
75
+ end
76
+ if hostval.include?("https://")
77
+ hostval["https://"] = ""
78
+ end
79
+ uri.host = hostval
80
+ uri.port = 80
81
+ end
82
+
71
83
  if http.respond_to?(:use_ssl?) && http.use_ssl?
72
84
  uri.scheme = "https"
73
85
  else
74
86
  uri.scheme = "http"
75
87
  end
76
88
 
89
+
77
90
  uri.to_s
78
91
  end
79
92
 
@@ -39,6 +39,9 @@ module OAuth
39
39
 
40
40
  # Default http method used for OAuth Token Requests (defaults to :post)
41
41
  :http_method => :post,
42
+
43
+ # Add a custom ca_file for consumer
44
+ # :ca_file => '/etc/certs.pem'
42
45
 
43
46
  # Add a custom ca_file for consumer
44
47
  # :ca_file => '/etc/certs.pem'
@@ -159,7 +162,6 @@ module OAuth
159
162
  req = create_signed_request(http_method, path, token, request_options, *arguments)
160
163
  return nil if block_given? and yield(req) == :done
161
164
  rsp = http.request(req)
162
-
163
165
  # check for an error reported by the Problem Reporting extension
164
166
  # (http://wiki.oauth.net/ProblemReporting)
165
167
  # note: a 200 may actually be an error; check for an oauth_problem key to be sure
@@ -232,6 +234,11 @@ module OAuth
232
234
  @options[:site].to_s
233
235
  end
234
236
 
237
+ def request_endpoint
238
+ return nil if @options[:request_endpoint].nil?
239
+ @options[:request_endpoint].to_s
240
+ end
241
+
235
242
  def scheme
236
243
  @options[:scheme]
237
244
  end
@@ -281,12 +288,20 @@ module OAuth
281
288
 
282
289
  # Instantiates the http object
283
290
  def create_http(_url = nil)
291
+
292
+
293
+ if !request_endpoint.nil?
294
+ _url = request_endpoint
295
+ end
296
+
297
+
284
298
  if _url.nil? || _url[0] =~ /^\//
285
299
  our_uri = URI.parse(site)
286
300
  else
287
301
  our_uri = URI.parse(_url)
288
302
  end
289
303
 
304
+
290
305
  if proxy.nil?
291
306
  http_object = Net::HTTP.new(our_uri.host, our_uri.port)
292
307
  else
@@ -303,7 +318,6 @@ module OAuth
303
318
  else
304
319
  http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE
305
320
  end
306
-
307
321
  http_object
308
322
  end
309
323
 
@@ -336,7 +350,7 @@ module OAuth
336
350
 
337
351
  if data.is_a?(Hash)
338
352
  form_data = {}
339
- data.each {|k,v| form_data[k.to_s] = v if !v.nil?}
353
+ data.each {|k,v| form_data[k.to_s] = v if !v.nil?}
340
354
  request.set_form_data(form_data)
341
355
  elsif data
342
356
  if data.respond_to?(:read)
@@ -34,7 +34,7 @@ module OAuth::RequestProxy
34
34
  end
35
35
 
36
36
  def request_params
37
- request.params
37
+ request.POST
38
38
  end
39
39
  end
40
40
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oauth}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
12
- s.date = %q{2010-04-21}
12
+ s.date = %q{2010-06-16}
13
13
  s.default_executable = %q{oauth}
14
14
  s.description = %q{OAuth Core Ruby implementation}
15
15
  s.email = %q{oauth-ruby@googlegroups.com}
@@ -1,6 +1,13 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/request_proxy/curb_request'
3
- require 'curb'
1
+ require 'test_helper'
2
+
3
+ begin
4
+ require 'oauth/request_proxy/curb_request'
5
+ require 'curb'
6
+ rescue LoadError => e
7
+ warn "! problems loading curb, skipping these tests: #{e}"
8
+ return
9
+ end
10
+
4
11
 
5
12
  class CurbRequestProxyTest < Test::Unit::TestCase
6
13
 
@@ -1,5 +1,10 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/client/em_http'
1
+ require 'test_helper'
2
+ begin
3
+ require 'oauth/client/em_http'
4
+ rescue LoadError => e
5
+ warn "! problem loading em-http, skipping these tests: #{e}"
6
+ return
7
+ end
3
8
 
4
9
  class EmHttpClientTest < Test::Unit::TestCase
5
10
 
@@ -1,6 +1,13 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'em-http'
3
- require 'oauth/request_proxy/em_http_request'
1
+ require 'test_helper'
2
+
3
+ begin
4
+ require 'em-http'
5
+ require 'oauth/request_proxy/em_http_request'
6
+ rescue LoadError => e
7
+ warn "! problem loading em-http, skipping these tests: #{e}"
8
+ return
9
+ end
10
+
4
11
 
5
12
  class EmHttpRequestProxyTest < Test::Unit::TestCase
6
13
 
@@ -1,6 +1,13 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'oauth/request_proxy/typhoeus_request'
3
- require 'typhoeus'
1
+ require 'test_helper'
2
+
3
+ begin
4
+ require 'oauth/request_proxy/typhoeus_request'
5
+ require 'typhoeus'
6
+ rescue LoadError => e
7
+ warn "! problem loading typhoeus, skipping these tests: #{e}"
8
+ return
9
+ end
10
+
4
11
 
5
12
  class TyphoeusRequestProxyTest < Test::Unit::TestCase
6
13
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pelle Braendgaard
@@ -21,7 +21,7 @@ autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
23
 
24
- date: 2010-04-21 00:00:00 -04:00
24
+ date: 2010-06-16 00:00:00 -04:00
25
25
  default_executable: oauth
26
26
  dependencies:
27
27
  - !ruby/object:Gem::Dependency