oauth 0.3.7.pre1 → 0.4.0

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/.gitignore CHANGED
@@ -1 +1,2 @@
1
- pkg/*
1
+ pkg/*
2
+ _site
@@ -1,4 +1,8 @@
1
- == 0.3.7
1
+ == 0.4.0 2010-04-22
2
+
3
+ * Added computation of oauth_body_hash as per OAuth Request Body Hash 1.0
4
+ Draft 4 (Michael Reinsch)
5
+ * Added the optional `oauth_session_handle` parameter for the Yahoo implementation (Will Bailey)
2
6
  * Better marshalling implementation (Yoan Blanc)
3
7
  * Added optional block to OAuth::Consumer.get_*_token (Neill Pearman)
4
8
  * Exclude `oauth_callback` with :exclude_callback (Neill Pearman)
@@ -13,6 +17,7 @@
13
17
  * Support for Typhoeus (Bill Kocik)
14
18
  * Support for em-http (EventMachine) (Darcy Laycock)
15
19
  * Support for curb (André Luis Leal Cardoso Junior)
20
+ * New website (Aaron Quint)
16
21
 
17
22
  == 0.3.6 2009-09-14
18
23
 
@@ -104,7 +109,9 @@
104
109
 
105
110
  == 0.2 2008-1-19 All together now release
106
111
 
107
- This is a big release, where we have merged the efforts of various parties into one common library. This means there are definitely some API changes you should be aware of. They should be minimal but please have a look at the unit tests.
112
+ This is a big release, where we have merged the efforts of various parties into one common library.
113
+ This means there are definitely some API changes you should be aware of. They should be minimal
114
+ but please have a look at the unit tests.
108
115
 
109
116
  == 0.1.2 2007-12-1
110
117
 
File without changes
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Ruby OAuth GEM
1
+ = Ruby OAuth
2
2
 
3
3
  == What
4
4
 
@@ -12,7 +12,7 @@ See the OAuth specs http://oauth.net/core/1.0/
12
12
 
13
13
  You can also install it from the oauth rubyforge project http://rubyforge.org/projects/oauth/.
14
14
 
15
- The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
15
+ The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
16
16
 
17
17
  == The basics
18
18
 
@@ -70,7 +70,7 @@ http://groups.google.com/group/oauth-ruby
70
70
 
71
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
72
 
73
- The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
73
+ The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
74
74
 
75
75
  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.
76
76
 
@@ -80,5 +80,8 @@ This code is free to use under the terms of the MIT license.
80
80
 
81
81
  == Contact
82
82
 
83
- Comments are welcome. Send an email to "Pelle Braendgaard" pelleb@gmail.com email via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
83
+ OAuth Ruby has been created and maintained by a large number of talented individuals.
84
+ The current maintainer is Aaron Quint (quirkey).
85
+
86
+ Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
84
87
 
data/Rakefile CHANGED
@@ -1,24 +1,23 @@
1
1
  %w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
2
2
  $LOAD_PATH << File.dirname(__FILE__) + '/lib'
3
3
  require 'oauth'
4
- require 'oauth/version'
5
4
 
6
5
  begin
7
6
  require 'jeweler'
8
7
  Jeweler::Tasks.new do |s|
9
8
  s.name = %q{oauth}
10
9
  s.version = OAuth::VERSION
11
- s.date = %q{2009-08-10}
12
10
  s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
13
11
  s.email = "oauth-ruby@googlegroups.com"
14
12
  s.description = "OAuth Core Ruby implementation"
15
13
  s.summary = s.description
16
14
  s.rubyforge_project = %q{oauth}
17
- s.add_development_dependency(%q<actionpack>, [">= 2.2.0"])
15
+ s.add_development_dependency(%q<actionpack>, [">= 2.2.0", "<2.3.0"])
18
16
  s.add_development_dependency(%q<rack>, [">= 1.0.0"])
19
17
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
20
18
  s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
21
19
  s.add_development_dependency(%q<em-http-request>)
20
+ s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
22
21
  end
23
22
  Jeweler::GemcutterTasks.new
24
23
  rescue LoadError
data/bin/oauth CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby -w -rubygems
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  require "oauth/cli"
4
4
 
5
- OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
5
+ OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
data/lib/oauth.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  $LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
2
 
3
+ module OAuth
4
+ VERSION = "0.4.0"
5
+ end
6
+
3
7
  require 'oauth/oauth'
4
8
  require 'oauth/core_ext'
5
9
 
6
10
  require 'oauth/client/helper'
7
11
  require 'oauth/signature/hmac/sha1'
8
- require 'oauth/request_proxy/mock_request'
12
+ require 'oauth/request_proxy/mock_request'
@@ -2,7 +2,6 @@ require 'oauth/client'
2
2
  require 'oauth/consumer'
3
3
  require 'oauth/helper'
4
4
  require 'oauth/token'
5
- require 'oauth/version'
6
5
  require 'oauth/signature/hmac/sha1'
7
6
 
8
7
  module OAuth::Client
@@ -29,6 +28,7 @@ module OAuth::Client
29
28
 
30
29
  def oauth_parameters
31
30
  {
31
+ 'oauth_body_hash' => options[:body_hash],
32
32
  'oauth_callback' => options[:oauth_callback],
33
33
  'oauth_consumer_key' => options[:consumer].key,
34
34
  'oauth_token' => options[:token] ? options[:token].token : '',
@@ -36,7 +36,8 @@ module OAuth::Client
36
36
  'oauth_timestamp' => timestamp,
37
37
  'oauth_nonce' => nonce,
38
38
  'oauth_verifier' => options[:oauth_verifier],
39
- 'oauth_version' => (options[:oauth_version] || '1.0')
39
+ 'oauth_version' => (options[:oauth_version] || '1.0'),
40
+ 'oauth_session_handle' => options[:oauth_session_handle]
40
41
  }.reject { |k,v| v.to_s == "" }
41
42
  end
42
43
 
@@ -55,6 +56,10 @@ module OAuth::Client
55
56
  :parameters => oauth_parameters}.merge(extra_options) )
56
57
  end
57
58
 
59
+ def hash_body
60
+ @options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters)
61
+ end
62
+
58
63
  def amend_user_agent_header(headers)
59
64
  @oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
60
65
  # Net::HTTP in 1.9 appends Ruby
@@ -20,19 +20,14 @@ class Net::HTTPRequest
20
20
  #
21
21
  # This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
22
22
  #
23
- # See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
23
+ # See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1],
24
+ # {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html]
24
25
  def oauth!(http, consumer = nil, token = nil, options = {})
25
- options = { :request_uri => oauth_full_request_uri(http),
26
- :consumer => consumer,
27
- :token => token,
28
- :scheme => 'header',
29
- :signature_method => nil,
30
- :nonce => nil,
31
- :timestamp => nil }.merge(options)
32
-
33
- @oauth_helper = OAuth::Client::Helper.new(self, options)
26
+ helper_options = oauth_helper_options(http, consumer, token, options)
27
+ @oauth_helper = OAuth::Client::Helper.new(self, helper_options)
34
28
  @oauth_helper.amend_user_agent_header(self)
35
- self.send("set_oauth_#{options[:scheme]}")
29
+ @oauth_helper.hash_body if oauth_body_hash_required?
30
+ self.send("set_oauth_#{helper_options[:scheme]}")
36
31
  end
37
32
 
38
33
  # Create a string suitable for signing for an HTTP request. This process involves parameter
@@ -47,21 +42,27 @@ class Net::HTTPRequest
47
42
  # * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
48
43
  # +signature_method+, +nonce+, +timestamp+)
49
44
  #
50
- # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
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
+ # {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html]
51
47
  def signature_base_string(http, consumer = nil, token = nil, options = {})
52
- options = { :request_uri => oauth_full_request_uri(http),
53
- :consumer => consumer,
54
- :token => token,
55
- :scheme => 'header',
56
- :signature_method => nil,
57
- :nonce => nil,
58
- :timestamp => nil }.merge(options)
59
-
60
- OAuth::Client::Helper.new(self, options).signature_base_string
48
+ helper_options = oauth_helper_options(http, consumer, token, options)
49
+ oauth_helper = OAuth::Client::Helper.new(self, helper_options)
50
+ oauth_helper.hash_body if oauth_body_hash_required?
51
+ oauth_helper.signature_base_string
61
52
  end
62
53
 
63
54
  private
64
55
 
56
+ def oauth_helper_options(http, consumer, token, options)
57
+ { :request_uri => oauth_full_request_uri(http),
58
+ :consumer => consumer,
59
+ :token => token,
60
+ :scheme => 'header',
61
+ :signature_method => nil,
62
+ :nonce => nil,
63
+ :timestamp => nil }.merge(options)
64
+ end
65
+
65
66
  def oauth_full_request_uri(http)
66
67
  uri = URI.parse(self.path)
67
68
  uri.host = http.address
@@ -76,6 +77,10 @@ private
76
77
  uri.to_s
77
78
  end
78
79
 
80
+ def oauth_body_hash_required?
81
+ request_body_permitted? && content_type != "application/x-www-form-urlencoded"
82
+ end
83
+
79
84
  def set_oauth_header
80
85
  self['Authorization'] = @oauth_helper.header
81
86
  end
@@ -76,10 +76,10 @@ module OAuth
76
76
  @secret = consumer_secret
77
77
 
78
78
  # ensure that keys are symbols
79
- @options = @@default_options.merge(options.inject({}) { |opts, (key, value)|
79
+ @options = @@default_options.merge(options.inject({}) do |opts, (key, value)|
80
80
  opts[key.to_sym] = value
81
81
  opts
82
- })
82
+ end)
83
83
  end
84
84
 
85
85
  # The default http method
@@ -128,10 +128,10 @@ module OAuth
128
128
 
129
129
  if block_given?
130
130
  response = token_request(http_method,
131
- (request_token_url? ? request_token_url : request_token_path),
132
- nil,
133
- request_options,
134
- *arguments, &block)
131
+ (request_token_url? ? request_token_url : request_token_path),
132
+ nil,
133
+ request_options,
134
+ *arguments, &block)
135
135
  else
136
136
  response = token_request(http_method, (request_token_url? ? request_token_url : request_token_path), nil, request_options, *arguments)
137
137
  end
@@ -277,7 +277,7 @@ module OAuth
277
277
  @options[:proxy]
278
278
  end
279
279
 
280
- protected
280
+ protected
281
281
 
282
282
  # Instantiates the http object
283
283
  def create_http(_url = nil)
@@ -358,9 +358,7 @@ module OAuth
358
358
  end
359
359
 
360
360
  def marshal_dump(*args)
361
- {:key => @key,
362
- :secret => @secret,
363
- :options => @options}
361
+ {:key => @key, :secret => @secret, :options => @options}
364
362
  end
365
363
 
366
364
  def marshal_load(data)
data/lib/oauth/oauth.rb CHANGED
@@ -4,7 +4,9 @@ module OAuth
4
4
  OUT_OF_BAND = "oob"
5
5
 
6
6
  # required parameters, per sections 6.1.1, 6.3.1, and 7
7
- PARAMETERS = %w(oauth_callback oauth_consumer_key oauth_token oauth_signature_method oauth_timestamp oauth_nonce oauth_verifier oauth_version oauth_signature)
7
+ PARAMETERS = %w(oauth_callback oauth_consumer_key oauth_token
8
+ oauth_signature_method oauth_timestamp oauth_nonce oauth_verifier
9
+ oauth_version oauth_signature oauth_body_hash)
8
10
 
9
11
  # reserved character regexp, per section 5.1
10
12
  RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
@@ -24,6 +24,10 @@ module OAuth::RequestProxy::Net
24
24
  end
25
25
  end
26
26
 
27
+ def body
28
+ request.body
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def all_parameters
@@ -35,6 +35,11 @@ module OAuth
35
35
  self.build(request, options, &block).signature_base_string
36
36
  end
37
37
 
38
+ # Create the body hash for a request
39
+ def self.body_hash(request, options = {}, &block)
40
+ self.build(request, options, &block).body_hash
41
+ end
42
+
38
43
  class UnknownSignatureMethod < Exception; end
39
44
  end
40
45
  end
@@ -26,6 +26,11 @@ module OAuth::Signature
26
26
  @digest_klass = digest_klass
27
27
  end
28
28
 
29
+ def self.hash_class(hash_class = nil)
30
+ return @hash_class if hash_class.nil?
31
+ @hash_class = hash_class
32
+ end
33
+
29
34
  def initialize(request, options = {}, &block)
30
35
  raise TypeError unless request.kind_of?(OAuth::RequestProxy::Base)
31
36
  @request = request
@@ -72,6 +77,14 @@ module OAuth::Signature
72
77
  request.signature_base_string
73
78
  end
74
79
 
80
+ def body_hash
81
+ if self.class.hash_class
82
+ Base64.encode64(self.class.hash_class.digest(request.body || '')).chomp.gsub(/\n/,'')
83
+ else
84
+ nil # no body hash algorithm defined, so don't generate one
85
+ end
86
+ end
87
+
75
88
  private
76
89
 
77
90
  def token
@@ -4,5 +4,6 @@ module OAuth::Signature::HMAC
4
4
  class SHA1 < Base
5
5
  implements 'hmac-sha1'
6
6
  digest_klass 'SHA1'
7
+ hash_class ::Digest::SHA1
7
8
  end
8
9
  end
@@ -4,6 +4,7 @@ require 'openssl'
4
4
  module OAuth::Signature::RSA
5
5
  class SHA1 < OAuth::Signature::Base
6
6
  implements 'rsa-sha1'
7
+ hash_class ::Digest::SHA1
7
8
 
8
9
  def ==(cmp_signature)
9
10
  public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(cmp_signature.is_a?(Array) ? cmp_signature.first : cmp_signature), signature_base_string)
data/oauth.gemspec CHANGED
@@ -5,24 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oauth}
8
- s.version = "0.3.7.pre1"
8
+ s.version = "0.4.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
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-02-15}
12
+ s.date = %q{2010-04-21}
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}
16
16
  s.executables = ["oauth"]
17
17
  s.extra_rdoc_files = [
18
- "README.rdoc",
18
+ "LICENSE",
19
+ "README.rdoc",
19
20
  "TODO"
20
21
  ]
21
22
  s.files = [
22
23
  ".gitignore",
23
- "History.txt",
24
- "License.txt",
25
- "Manifest.txt",
24
+ "HISTORY",
25
+ "LICENSE",
26
26
  "README.rdoc",
27
27
  "Rakefile",
28
28
  "TODO",
@@ -73,12 +73,7 @@ Gem::Specification.new do |s|
73
73
  "lib/oauth/tokens/request_token.rb",
74
74
  "lib/oauth/tokens/server_token.rb",
75
75
  "lib/oauth/tokens/token.rb",
76
- "lib/oauth/version.rb",
77
76
  "oauth.gemspec",
78
- "script/destroy",
79
- "script/generate",
80
- "script/txt2html",
81
- "setup.rb",
82
77
  "tasks/deployment.rake",
83
78
  "tasks/environment.rake",
84
79
  "tasks/website.rake",
@@ -109,17 +104,12 @@ Gem::Specification.new do |s|
109
104
  "test/test_signature_base.rb",
110
105
  "test/test_signature_plain_text.rb",
111
106
  "test/test_token.rb",
112
- "test/test_typhoeus_request_proxy.rb",
113
- "website/index.html",
114
- "website/index.txt",
115
- "website/javascripts/rounded_corners_lite.inc.js",
116
- "website/stylesheets/screen.css",
117
- "website/template.rhtml"
107
+ "test/test_typhoeus_request_proxy.rb"
118
108
  ]
119
109
  s.rdoc_options = ["--charset=UTF-8"]
120
110
  s.require_paths = ["lib"]
121
111
  s.rubyforge_project = %q{oauth}
122
- s.rubygems_version = %q{1.3.5}
112
+ s.rubygems_version = %q{1.3.6}
123
113
  s.summary = %q{OAuth Core Ruby implementation}
124
114
  s.test_files = [
125
115
  "test/cases/oauth_case.rb",
@@ -156,24 +146,27 @@ Gem::Specification.new do |s|
156
146
  s.specification_version = 3
157
147
 
158
148
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
159
- s.add_development_dependency(%q<actionpack>, [">= 2.2.0"])
149
+ s.add_development_dependency(%q<actionpack>, [">= 2.2.0", "< 2.3.0"])
160
150
  s.add_development_dependency(%q<rack>, [">= 1.0.0"])
161
151
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
162
152
  s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
163
153
  s.add_development_dependency(%q<em-http-request>, [">= 0"])
154
+ s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
164
155
  else
165
- s.add_dependency(%q<actionpack>, [">= 2.2.0"])
156
+ s.add_dependency(%q<actionpack>, [">= 2.2.0", "< 2.3.0"])
166
157
  s.add_dependency(%q<rack>, [">= 1.0.0"])
167
158
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
168
159
  s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
169
160
  s.add_dependency(%q<em-http-request>, [">= 0"])
161
+ s.add_dependency(%q<curb>, [">= 0.6.6.0"])
170
162
  end
171
163
  else
172
- s.add_dependency(%q<actionpack>, [">= 2.2.0"])
164
+ s.add_dependency(%q<actionpack>, [">= 2.2.0", "< 2.3.0"])
173
165
  s.add_dependency(%q<rack>, [">= 1.0.0"])
174
166
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
175
167
  s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
176
168
  s.add_dependency(%q<em-http-request>, [">= 0"])
169
+ s.add_dependency(%q<curb>, [">= 0.6.6.0"])
177
170
  end
178
171
  end
179
172