oauth 0.4.7 → 0.5.4

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.

Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +21 -10
  3. data/bin/oauth +8 -2
  4. data/lib/oauth.rb +3 -5
  5. data/lib/oauth/cli.rb +37 -359
  6. data/lib/oauth/cli/authorize_command.rb +71 -0
  7. data/lib/oauth/cli/base_command.rb +208 -0
  8. data/lib/oauth/cli/help_command.rb +22 -0
  9. data/lib/oauth/cli/query_command.rb +25 -0
  10. data/lib/oauth/cli/sign_command.rb +81 -0
  11. data/lib/oauth/cli/version_command.rb +7 -0
  12. data/lib/oauth/client/action_controller_request.rb +1 -1
  13. data/lib/oauth/client/em_http.rb +0 -1
  14. data/lib/oauth/client/helper.rb +4 -0
  15. data/lib/oauth/client/net_http.rb +9 -8
  16. data/lib/oauth/consumer.rb +35 -8
  17. data/lib/oauth/helper.rb +11 -7
  18. data/lib/oauth/request_proxy/action_controller_request.rb +27 -3
  19. data/lib/oauth/request_proxy/action_dispatch_request.rb +7 -0
  20. data/lib/oauth/request_proxy/base.rb +7 -3
  21. data/lib/oauth/request_proxy/net_http.rb +1 -1
  22. data/lib/oauth/request_proxy/rest_client_request.rb +62 -0
  23. data/lib/oauth/request_proxy/typhoeus_request.rb +4 -3
  24. data/lib/oauth/signature/base.rb +9 -23
  25. data/lib/oauth/signature/hmac/sha1.rb +12 -4
  26. data/lib/oauth/signature/plaintext.rb +6 -0
  27. data/lib/oauth/signature/rsa/sha1.rb +7 -3
  28. data/lib/oauth/tokens/access_token.rb +12 -0
  29. data/lib/oauth/tokens/request_token.rb +6 -1
  30. data/lib/oauth/tokens/token.rb +1 -1
  31. data/lib/oauth/version.rb +3 -0
  32. metadata +147 -103
  33. data/.gemtest +0 -0
  34. data/Gemfile +0 -16
  35. data/Gemfile.lock +0 -47
  36. data/HISTORY +0 -173
  37. data/Rakefile +0 -37
  38. data/examples/yql.rb +0 -44
  39. data/lib/digest/hmac.rb +0 -104
  40. data/lib/oauth/core_ext.rb +0 -31
  41. data/lib/oauth/signature/hmac/base.rb +0 -15
  42. data/lib/oauth/signature/hmac/md5.rb +0 -8
  43. data/lib/oauth/signature/hmac/rmd160.rb +0 -8
  44. data/lib/oauth/signature/hmac/sha2.rb +0 -8
  45. data/lib/oauth/signature/md5.rb +0 -13
  46. data/lib/oauth/signature/sha1.rb +0 -13
  47. data/oauth.gemspec +0 -148
  48. data/tasks/deployment.rake +0 -34
  49. data/tasks/environment.rake +0 -7
  50. data/tasks/website.rake +0 -17
  51. data/test/cases/oauth_case.rb +0 -19
  52. data/test/cases/spec/1_0-final/test_construct_request_url.rb +0 -62
  53. data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +0 -88
  54. data/test/cases/spec/1_0-final/test_parameter_encodings.rb +0 -86
  55. data/test/cases/spec/1_0-final/test_signature_base_strings.rb +0 -77
  56. data/test/integration/consumer_test.rb +0 -307
  57. data/test/keys/rsa.cert +0 -11
  58. data/test/keys/rsa.pem +0 -16
  59. data/test/test_access_token.rb +0 -26
  60. data/test/test_action_controller_request_proxy.rb +0 -133
  61. data/test/test_consumer.rb +0 -220
  62. data/test/test_curb_request_proxy.rb +0 -77
  63. data/test/test_em_http_client.rb +0 -80
  64. data/test/test_em_http_request_proxy.rb +0 -115
  65. data/test/test_helper.rb +0 -28
  66. data/test/test_hmac_sha1.rb +0 -20
  67. data/test/test_net_http_client.rb +0 -292
  68. data/test/test_net_http_request_proxy.rb +0 -72
  69. data/test/test_oauth_helper.rb +0 -94
  70. data/test/test_rack_request_proxy.rb +0 -40
  71. data/test/test_request_token.rb +0 -51
  72. data/test/test_rsa_sha1.rb +0 -59
  73. data/test/test_server.rb +0 -40
  74. data/test/test_signature.rb +0 -22
  75. data/test/test_signature_base.rb +0 -32
  76. data/test/test_signature_plain_text.rb +0 -31
  77. data/test/test_token.rb +0 -14
  78. data/test/test_typhoeus_request_proxy.rb +0 -80
@@ -1,15 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'oauth/signature/base'
4
- require 'digest/hmac'
5
-
6
- module OAuth::Signature::HMAC
7
- class Base < OAuth::Signature::Base
8
-
9
- private
10
- def digest
11
- self.class.digest_class Object.module_eval("::Digest::#{self.class.digest_klass}")
12
- Digest::HMAC.digest(signature_base_string, secret, self.class.digest_class)
13
- end
14
- end
15
- end
@@ -1,8 +0,0 @@
1
- require 'oauth/signature/hmac/base'
2
-
3
- module OAuth::Signature::HMAC
4
- class MD5 < Base
5
- implements 'hmac-md5'
6
- digest_class 'MD5'
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'oauth/signature/hmac/base'
2
-
3
- module OAuth::Signature::HMAC
4
- class RMD160 < Base
5
- implements 'hmac-rmd160'
6
- digest_klass 'RMD160'
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'oauth/signature/hmac/base'
2
-
3
- module OAuth::Signature::HMAC
4
- class SHA2 < Base
5
- implements 'hmac-sha2'
6
- digest_klass 'SHA2'
7
- end
8
- end
@@ -1,13 +0,0 @@
1
- require 'oauth/signature/base'
2
- require 'digest/md5'
3
-
4
- module OAuth::Signature
5
- class MD5 < Base
6
- implements 'md5'
7
- digest_class Digest::MD5
8
-
9
- def signature_base_string
10
- secret + super
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'oauth/signature/base'
2
- require 'digest/sha1'
3
-
4
- module OAuth::Signature
5
- class SHA1 < Base
6
- implements 'sha1'
7
- digest_class Digest::SHA1
8
-
9
- def signature_base_string
10
- secret + super
11
- end
12
- end
13
- end
@@ -1,148 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "oauth"
8
- s.version = "0.4.7"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
12
- s.date = "2012-09-04"
13
- s.description = "OAuth Core Ruby implementation"
14
- s.email = "oauth-ruby@googlegroups.com"
15
- s.executables = ["oauth"]
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.rdoc",
19
- "TODO"
20
- ]
21
- s.files = [
22
- ".gemtest",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "HISTORY",
26
- "LICENSE",
27
- "README.rdoc",
28
- "Rakefile",
29
- "TODO",
30
- "bin/oauth",
31
- "examples/yql.rb",
32
- "lib/digest/hmac.rb",
33
- "lib/oauth.rb",
34
- "lib/oauth/cli.rb",
35
- "lib/oauth/client.rb",
36
- "lib/oauth/client/action_controller_request.rb",
37
- "lib/oauth/client/em_http.rb",
38
- "lib/oauth/client/helper.rb",
39
- "lib/oauth/client/net_http.rb",
40
- "lib/oauth/consumer.rb",
41
- "lib/oauth/core_ext.rb",
42
- "lib/oauth/errors.rb",
43
- "lib/oauth/errors/error.rb",
44
- "lib/oauth/errors/problem.rb",
45
- "lib/oauth/errors/unauthorized.rb",
46
- "lib/oauth/helper.rb",
47
- "lib/oauth/oauth.rb",
48
- "lib/oauth/oauth_test_helper.rb",
49
- "lib/oauth/request_proxy.rb",
50
- "lib/oauth/request_proxy/action_controller_request.rb",
51
- "lib/oauth/request_proxy/base.rb",
52
- "lib/oauth/request_proxy/curb_request.rb",
53
- "lib/oauth/request_proxy/em_http_request.rb",
54
- "lib/oauth/request_proxy/jabber_request.rb",
55
- "lib/oauth/request_proxy/mock_request.rb",
56
- "lib/oauth/request_proxy/net_http.rb",
57
- "lib/oauth/request_proxy/rack_request.rb",
58
- "lib/oauth/request_proxy/typhoeus_request.rb",
59
- "lib/oauth/server.rb",
60
- "lib/oauth/signature.rb",
61
- "lib/oauth/signature/base.rb",
62
- "lib/oauth/signature/hmac/base.rb",
63
- "lib/oauth/signature/hmac/md5.rb",
64
- "lib/oauth/signature/hmac/rmd160.rb",
65
- "lib/oauth/signature/hmac/sha1.rb",
66
- "lib/oauth/signature/hmac/sha2.rb",
67
- "lib/oauth/signature/md5.rb",
68
- "lib/oauth/signature/plaintext.rb",
69
- "lib/oauth/signature/rsa/sha1.rb",
70
- "lib/oauth/signature/sha1.rb",
71
- "lib/oauth/token.rb",
72
- "lib/oauth/tokens/access_token.rb",
73
- "lib/oauth/tokens/consumer_token.rb",
74
- "lib/oauth/tokens/request_token.rb",
75
- "lib/oauth/tokens/server_token.rb",
76
- "lib/oauth/tokens/token.rb",
77
- "oauth.gemspec",
78
- "tasks/deployment.rake",
79
- "tasks/environment.rake",
80
- "tasks/website.rake",
81
- "test/cases/oauth_case.rb",
82
- "test/cases/spec/1_0-final/test_construct_request_url.rb",
83
- "test/cases/spec/1_0-final/test_normalize_request_parameters.rb",
84
- "test/cases/spec/1_0-final/test_parameter_encodings.rb",
85
- "test/cases/spec/1_0-final/test_signature_base_strings.rb",
86
- "test/integration/consumer_test.rb",
87
- "test/keys/rsa.cert",
88
- "test/keys/rsa.pem",
89
- "test/test_access_token.rb",
90
- "test/test_action_controller_request_proxy.rb",
91
- "test/test_consumer.rb",
92
- "test/test_curb_request_proxy.rb",
93
- "test/test_em_http_client.rb",
94
- "test/test_em_http_request_proxy.rb",
95
- "test/test_helper.rb",
96
- "test/test_hmac_sha1.rb",
97
- "test/test_net_http_client.rb",
98
- "test/test_net_http_request_proxy.rb",
99
- "test/test_oauth_helper.rb",
100
- "test/test_rack_request_proxy.rb",
101
- "test/test_request_token.rb",
102
- "test/test_rsa_sha1.rb",
103
- "test/test_server.rb",
104
- "test/test_signature.rb",
105
- "test/test_signature_base.rb",
106
- "test/test_signature_plain_text.rb",
107
- "test/test_token.rb",
108
- "test/test_typhoeus_request_proxy.rb"
109
- ]
110
- s.require_paths = ["lib"]
111
- s.rubyforge_project = "oauth"
112
- s.rubygems_version = "1.8.23"
113
- s.summary = "OAuth Core Ruby implementation"
114
-
115
- if s.respond_to? :specification_version then
116
- s.specification_version = 3
117
-
118
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
119
- s.add_development_dependency(%q<rake>, [">= 0"])
120
- s.add_development_dependency(%q<jeweler>, [">= 0"])
121
- s.add_development_dependency(%q<actionpack>, [">= 2.3.5"])
122
- s.add_development_dependency(%q<rack>, [">= 1.0.0"])
123
- s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
124
- s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
125
- s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
126
- s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
127
- else
128
- s.add_dependency(%q<rake>, [">= 0"])
129
- s.add_dependency(%q<jeweler>, [">= 0"])
130
- s.add_dependency(%q<actionpack>, [">= 2.3.5"])
131
- s.add_dependency(%q<rack>, [">= 1.0.0"])
132
- s.add_dependency(%q<mocha>, [">= 0.9.8"])
133
- s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
134
- s.add_dependency(%q<em-http-request>, [">= 0.2.10"])
135
- s.add_dependency(%q<curb>, [">= 0.6.6.0"])
136
- end
137
- else
138
- s.add_dependency(%q<rake>, [">= 0"])
139
- s.add_dependency(%q<jeweler>, [">= 0"])
140
- s.add_dependency(%q<actionpack>, [">= 2.3.5"])
141
- s.add_dependency(%q<rack>, [">= 1.0.0"])
142
- s.add_dependency(%q<mocha>, [">= 0.9.8"])
143
- s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
144
- s.add_dependency(%q<em-http-request>, [">= 0.2.10"])
145
- s.add_dependency(%q<curb>, [">= 0.6.6.0"])
146
- end
147
- end
148
-
@@ -1,34 +0,0 @@
1
- desc 'Release the website and new gem version'
2
- task :deploy => [:check_version, :website, :release] do
3
- puts "Remember to create SVN tag:"
4
- puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
- puts "Suggested comment:"
7
- puts "Tagging release #{CHANGES}"
8
- end
9
-
10
- desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
- task :local_deploy => [:website_generate, :install_gem]
12
-
13
- task :check_version do
14
- unless ENV['VERSION']
15
- puts 'Must pass a VERSION=x.y.z release version'
16
- exit
17
- end
18
- unless ENV['VERSION'] == VERS
19
- puts "Please update your version.rb to match the release version, currently #{VERS}"
20
- exit
21
- end
22
- end
23
-
24
- desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
- task :install_gem_no_doc => [:clean, :package] do
26
- sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
- end
28
-
29
- namespace :manifest do
30
- desc 'Recreate Manifest.txt to include ALL files'
31
- task :refresh do
32
- `rake check_manifest | patch -p0 > Manifest.txt`
33
- end
34
- end
@@ -1,7 +0,0 @@
1
- task :ruby_env do
2
- RUBY_APP = if RUBY_PLATFORM =~ /java/
3
- "jruby"
4
- else
5
- "ruby"
6
- end unless defined? RUBY_APP
7
- end
@@ -1,17 +0,0 @@
1
- desc 'Generate website files'
2
- task :website_generate => :ruby_env do
3
- (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
- sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
- end
6
- end
7
-
8
- desc 'Upload website files to rubyforge'
9
- task :website_upload do
10
- host = "#{rubyforge_username}@rubyforge.org"
11
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
12
- local_dir = 'website'
13
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
- end
15
-
16
- desc 'Generate and upload website files'
17
- task :website => [:website_generate, :website_upload, :publish_docs]
@@ -1,19 +0,0 @@
1
- require 'test/unit'
2
- require 'oauth/signature'
3
- require 'oauth/request_proxy/mock_request'
4
-
5
-
6
- class OAuthCase < Test::Unit::TestCase
7
- # avoid whining about a lack of tests
8
- def run(*args)
9
- return if @method_name.to_s == "default_test"
10
- super
11
- end
12
-
13
- protected
14
-
15
- # Creates a fake request
16
- def request(params={},method='GET',uri="http://photos.example.net/photos")
17
- OAuth::RequestProxy.proxy({'parameters'=>params,'method'=>method,'uri'=>uri})
18
- end
19
- end
@@ -1,62 +0,0 @@
1
- require File.expand_path('../../../oauth_case', __FILE__)
2
-
3
- # See http://oauth.net/core/1.0/#anchor14
4
- #
5
- #9.1.2. Construct Request URL
6
- #
7
- #The Signature Base String includes the request absolute URL, tying the signature to a specific endpoint. The URL used in the Signature Base String MUST include the scheme, authority, and path, and MUST exclude the query and fragment as defined by [RFC3986] section 3.
8
- #
9
- #If the absolute request URL is not available to the Service Provider (it is always available to the Consumer), it can be constructed by combining the scheme being used, the HTTP Host header, and the relative HTTP request URL. If the Host header is not available, the Service Provider SHOULD use the host name communicated to the Consumer in the documentation or other means.
10
- #
11
- #The Service Provider SHOULD document the form of URL used in the Signature Base String to avoid ambiguity due to URL normalization. Unless specified, URL scheme and authority MUST be lowercase and include the port number; http default port 80 and https default port 443 MUST be excluded.
12
- #
13
- #For example, the request:
14
- #
15
- # HTTP://Example.com:80/resource?id=123
16
- #Is included in the Signature Base String as:
17
- #
18
- # http://example.com/resource
19
-
20
-
21
- class ConstructRequestUrlTest < OAuthCase
22
-
23
- def test_from_spec
24
- assert_request_url("http://example.com/resource","HTTP://Example.com:80/resource?id=123")
25
- end
26
-
27
- def test_simple_url_with_ending_slash
28
- assert_request_url("http://example.com/","http://example.com/")
29
- end
30
-
31
- def test_simple_url_without_ending_slash
32
- assert_request_url("http://example.com/","http://example.com")
33
- end
34
-
35
- def test_of_normalized_http
36
- assert_request_url("http://example.com/resource","http://example.com/resource")
37
- end
38
-
39
- def test_of_https
40
- assert_request_url("https://example.com/resource","HTTPS://Example.com:443/resource?id=123")
41
- end
42
-
43
- def test_of_normalized_https
44
- assert_request_url("https://example.com/resource","https://example.com/resource")
45
- end
46
-
47
- def test_of_http_with_non_standard_port
48
- assert_request_url("http://example.com:8080/resource","http://example.com:8080/resource")
49
- end
50
-
51
- def test_of_https_with_non_standard_port
52
- assert_request_url("https://example.com:8080/resource","https://example.com:8080/resource")
53
- end
54
-
55
- protected
56
-
57
-
58
- def assert_request_url(expected,given,message=nil)
59
- assert_equal expected, request({},'GET',given).normalized_uri, message
60
- end
61
-
62
- end
@@ -1,88 +0,0 @@
1
- require File.expand_path('../../../oauth_case', __FILE__)
2
-
3
- # See http://oauth.net/core/1.0/#anchor14
4
- #
5
- # 9.1.1. Normalize Request Parameters
6
- #
7
- # The request parameters are collected, sorted and concatenated into a normalized string:
8
- #
9
- # Parameters in the OAuth HTTP Authorization header excluding the realm parameter.
10
- # Parameters in the HTTP POST request body (with a content-type of application/x-www-form-urlencoded).
11
- # HTTP GET parameters added to the URLs in the query part (as defined by [RFC3986] section 3).
12
- # The oauth_signature parameter MUST be excluded.
13
- #
14
- # The parameters are normalized into a single string as follows:
15
- #
16
- # Parameters are sorted by name, using lexicographical byte value ordering.
17
- # If two or more parameters share the same name, they are sorted by their value. For example:
18
- #
19
- # a=1, c=hi%20there, f=25, f=50, f=a, z=p, z=t
20
- # Parameters are concatenated in their sorted order into a single string. For each parameter,
21
- # the name is separated from the corresponding value by an ‘=’ character (ASCII code 61), even
22
- # if the value is empty. Each name-value pair is separated by an ‘&’ character (ASCII code 38). For example:
23
- # a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t
24
- #
25
-
26
-
27
- class NormalizeRequestParametersTest < OAuthCase
28
-
29
- def test_parameters_for_signature
30
- params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'}
31
- assert_equal params,request(params).parameters_for_signature
32
- end
33
-
34
-
35
- def test_parameters_for_signature_removes_oauth_signature
36
- params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'}
37
- assert_equal params,request(params.merge({'oauth_signature'=>'blalbla'})).parameters_for_signature
38
- end
39
-
40
- def test_spec_example
41
- assert_normalized 'a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t', { 'a' => 1, 'c' => 'hi there', 'f' => ['25', '50', 'a'], 'z' => ['p', 't'] }
42
- end
43
-
44
- def test_sorts_parameters_correctly
45
- # values for 'f' are scrambled
46
- assert_normalized 'a=1&c=hi%20there&f=5&f=70&f=a&z=p&z=t', { 'a' => 1, 'c' => 'hi there', 'f' => ['a', '70', '5'], 'z' => ['p', 't'] }
47
- end
48
-
49
- def test_empty
50
- assert_normalized "",{}
51
- end
52
-
53
-
54
- # These are from the wiki http://wiki.oauth.net/TestCases
55
- # in the section Normalize Request Parameters
56
- # Parameters have already been x-www-form-urlencoded (i.e. + = <space>)
57
- def test_wiki1
58
- assert_normalized "name=",{"name"=>nil}
59
- end
60
-
61
- def test_wiki2
62
- assert_normalized "a=b",{'a'=>'b'}
63
- end
64
-
65
- def test_wiki3
66
- assert_normalized "a=b&c=d",{'a'=>'b','c'=>'d'}
67
- end
68
-
69
- def test_wiki4
70
- assert_normalized "a=x%20y&a=x%21y",{'a'=>["x!y","x y"]}
71
-
72
- end
73
-
74
- def test_wiki5
75
- assert_normalized "x=a&x%21y=a",{"x!y"=>'a','x'=>'a'}
76
- end
77
-
78
- protected
79
-
80
-
81
- def assert_normalized(expected,params,message=nil)
82
- assert_equal expected, normalize_request_parameters(params), message
83
- end
84
-
85
- def normalize_request_parameters(params={})
86
- request(params).normalized_parameters
87
- end
88
- end