roauth 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +7 -6
- data/Rakefile +16 -2
- data/VERSION +1 -1
- data/lib/roauth.rb +7 -7
- data/roauth.gemspec +9 -3
- data/test/helper.rb +10 -0
- data/test/test_roauth.rb +47 -0
- metadata +8 -15
- data/.gitignore +0 -2
data/README.markdown
CHANGED
@@ -6,7 +6,10 @@ A *simple* OAuth library that supports OAuth header signing, and header verifyin
|
|
6
6
|
|
7
7
|
Example Client:
|
8
8
|
|
9
|
-
|
9
|
+
require "roauth"
|
10
|
+
require "nestful"
|
11
|
+
|
12
|
+
url = "https://twitter.com/direct_messages.json"
|
10
13
|
|
11
14
|
oauth = {
|
12
15
|
:consumer_key => "consumer_key",
|
@@ -19,11 +22,9 @@ Example Client:
|
|
19
22
|
:count => "11",
|
20
23
|
:since_id => "5000"
|
21
24
|
}
|
22
|
-
oauth_header = ROAuth.header(oauth,
|
23
|
-
|
24
|
-
|
25
|
-
request = Net::HTTP.new(http_uri.host, http_uri.port)
|
26
|
-
request.get(uri.request_uri, {'Authorization', oauth_header})
|
25
|
+
oauth_header = ROAuth.header(oauth, url, params)
|
26
|
+
|
27
|
+
Nestful.get(url, :params => params, :headers => {'Authorization' => oauth_header})
|
27
28
|
|
28
29
|
Example Server:
|
29
30
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
1
4
|
begin
|
2
5
|
require 'jeweler'
|
3
6
|
Jeweler::Tasks.new do |gemspec|
|
@@ -9,5 +12,16 @@ begin
|
|
9
12
|
gemspec.authors = ["Alex MacCaw"]
|
10
13
|
end
|
11
14
|
rescue LoadError
|
12
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
13
|
-
end
|
15
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/test_*.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
task :test => :check_dependencies
|
27
|
+
task :default => :test
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/roauth.rb
CHANGED
@@ -77,7 +77,7 @@ module ROAuth
|
|
77
77
|
uri.query = nil
|
78
78
|
uri = uri.to_s
|
79
79
|
|
80
|
-
sig_base = http_method.to_s.upcase + "&" + escape(uri) + "&" + normalize(params)
|
80
|
+
sig_base = http_method.to_s.upcase + "&" + escape(uri) + "&" + escape(normalize(params))
|
81
81
|
digest = SIGNATURE_METHODS[oauth[:signature_method]]
|
82
82
|
secret = "#{escape(oauth[:consumer_secret])}&#{escape(oauth[:token_secret])}"
|
83
83
|
|
@@ -97,17 +97,17 @@ module ROAuth
|
|
97
97
|
def normalize(params)
|
98
98
|
# Stringify keys - so we can compare them
|
99
99
|
params.keys.each {|key| params[key.to_s] = params.delete(key) }
|
100
|
-
params.
|
100
|
+
params.sort_by {|key, values| key.to_s }.map do |key, values|
|
101
101
|
if values.is_a?(Array)
|
102
102
|
# Multiple values were provided for a single key
|
103
103
|
# in a hash
|
104
|
-
values.
|
105
|
-
[escape(key), escape(v)] * "
|
104
|
+
values.sort_by(&:to_s).collect do |v|
|
105
|
+
[escape(key), escape(v)] * "="
|
106
106
|
end
|
107
107
|
else
|
108
|
-
[escape(key), escape(values)] * "
|
108
|
+
[escape(key), escape(values)] * "="
|
109
109
|
end
|
110
|
-
end * "
|
110
|
+
end * "&"
|
111
111
|
end
|
112
112
|
extend self
|
113
|
-
end
|
113
|
+
end
|
data/roauth.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{roauth}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex MacCaw"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-13}
|
13
13
|
s.description = %q{Simple Ruby OAuth library}
|
14
14
|
s.email = %q{info@eribium.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,13 +23,19 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
25
|
"lib/roauth.rb",
|
26
|
-
"roauth.gemspec"
|
26
|
+
"roauth.gemspec",
|
27
|
+
"test/helper.rb",
|
28
|
+
"test/test_roauth.rb"
|
27
29
|
]
|
28
30
|
s.homepage = %q{http://github.com/maccman/roauth}
|
29
31
|
s.rdoc_options = ["--charset=UTF-8"]
|
30
32
|
s.require_paths = ["lib"]
|
31
33
|
s.rubygems_version = %q{1.3.7}
|
32
34
|
s.summary = %q{Simple Ruby OAuth library}
|
35
|
+
s.test_files = [
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/test_roauth.rb"
|
38
|
+
]
|
33
39
|
|
34
40
|
if s.respond_to? :specification_version then
|
35
41
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/test/helper.rb
ADDED
data/test/test_roauth.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestRoauth < Test::Unit::TestCase
|
4
|
+
should "correctly sign params" do
|
5
|
+
url = "https://twitter.com/direct_messages.json"
|
6
|
+
|
7
|
+
oauth = {
|
8
|
+
:consumer_key => "consumer_key",
|
9
|
+
:consumer_secret => "consumer_secret",
|
10
|
+
:access_key => "access_key",
|
11
|
+
:access_secret => "access_secret",
|
12
|
+
:nonce => "foo",
|
13
|
+
:timestamp => 1286967499
|
14
|
+
}
|
15
|
+
|
16
|
+
params = {
|
17
|
+
:count => "11",
|
18
|
+
:since_id => "5000"
|
19
|
+
}
|
20
|
+
|
21
|
+
oauth_header = ROAuth.header(oauth, url, params)
|
22
|
+
signature = ROAuth.parse(oauth_header)[:signature]
|
23
|
+
|
24
|
+
assert_equal "9/g1ge6nLYVkBsTEqgxH0Xlv2O4=", signature
|
25
|
+
end
|
26
|
+
|
27
|
+
should "verify correctly signed params" do
|
28
|
+
url = "https://twitter.com/direct_messages.json"
|
29
|
+
|
30
|
+
oauth = {
|
31
|
+
:consumer_key => "consumer_key",
|
32
|
+
:consumer_secret => "consumer_secret",
|
33
|
+
:access_key => "access_key",
|
34
|
+
:access_secret => "access_secret",
|
35
|
+
:nonce => "foo",
|
36
|
+
:timestamp => 1286967499
|
37
|
+
}
|
38
|
+
|
39
|
+
params = {
|
40
|
+
:count => "11",
|
41
|
+
:since_id => "5000"
|
42
|
+
}
|
43
|
+
|
44
|
+
header = %{OAuth oauth_consumer_key="consumer_key", oauth_nonce="foo", oauth_signature="9%2Fg1ge6nLYVkBsTEqgxH0Xlv2O4%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1286967499", oauth_token="access_key", oauth_version="1.0"}
|
45
|
+
assert ROAuth.verify(oauth, header, url, params), "verify failed"
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.7
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Alex MacCaw
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-06-09 00:00:00 -07:00
|
18
14
|
default_executable:
|
19
15
|
dependencies: []
|
20
16
|
|
@@ -28,20 +24,21 @@ extra_rdoc_files:
|
|
28
24
|
- LICENSE
|
29
25
|
- README.markdown
|
30
26
|
files:
|
31
|
-
- .gitignore
|
32
27
|
- LICENSE
|
33
28
|
- README.markdown
|
34
29
|
- Rakefile
|
35
30
|
- VERSION
|
36
31
|
- lib/roauth.rb
|
37
32
|
- roauth.gemspec
|
33
|
+
- test/helper.rb
|
34
|
+
- test/test_roauth.rb
|
38
35
|
has_rdoc: true
|
39
36
|
homepage: http://github.com/maccman/roauth
|
40
37
|
licenses: []
|
41
38
|
|
42
39
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
|
40
|
+
rdoc_options: []
|
41
|
+
|
45
42
|
require_paths:
|
46
43
|
- lib
|
47
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -49,21 +46,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
46
|
requirements:
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
|
-
segments:
|
53
|
-
- 0
|
54
49
|
version: "0"
|
55
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
51
|
none: false
|
57
52
|
requirements:
|
58
53
|
- - ">="
|
59
54
|
- !ruby/object:Gem::Version
|
60
|
-
segments:
|
61
|
-
- 0
|
62
55
|
version: "0"
|
63
56
|
requirements: []
|
64
57
|
|
65
58
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.6.0
|
67
60
|
signing_key:
|
68
61
|
specification_version: 3
|
69
62
|
summary: Simple Ruby OAuth library
|
data/.gitignore
DELETED