pusher 0.4.0.beta.1 → 0.4.0.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0.beta.1
1
+ 0.4.0.beta.2
@@ -44,9 +44,7 @@ module Authentication
44
44
  :auth_timestamp => Time.now.to_i
45
45
  }
46
46
 
47
- hmac_signature = HMAC::SHA256.digest(token.secret, string_to_sign)
48
- # chomp because the Base64 output ends with \n
49
- @auth_hash[:auth_signature] = Base64.encode64(hmac_signature).chomp
47
+ @auth_hash[:auth_signature] = signature(token)
50
48
 
51
49
  return @auth_hash
52
50
  end
@@ -92,6 +90,10 @@ module Authentication
92
90
 
93
91
  private
94
92
 
93
+ def signature(token)
94
+ HMAC::SHA256.hexdigest(token.secret, string_to_sign)
95
+ end
96
+
95
97
  def string_to_sign
96
98
  [@method, @path, parameter_string].join("\n")
97
99
  end
@@ -130,13 +132,9 @@ module Authentication
130
132
  end
131
133
 
132
134
  def validate_signature!(token)
133
- string = string_to_sign
134
- hmac_signature = HMAC::SHA256.digest(token.secret, string)
135
- # chomp because the Base64 output ends with \n
136
- base64_signature = Base64.encode64(hmac_signature).chomp
137
- unless @auth_hash["auth_signature"] == base64_signature
135
+ unless @auth_hash["auth_signature"] == signature(token)
138
136
  raise AuthenticationError, "Invalid signature: you should have "\
139
- "sent Base64Encode(HmacSHA256(#{string.inspect}, your_secret_key))"
137
+ "sent HmacSHA256Hex(#{string_to_sign.inspect}, your_secret_key)"
140
138
  end
141
139
  return true
142
140
  end
data/pusher.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pusher}
8
- s.version = "0.4.0.beta.1"
8
+ s.version = "0.4.0.beta.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["New Bamboo"]
12
- s.date = %q{2010-04-22}
12
+ s.date = %q{2010-04-23}
13
13
  s.description = %q{Wrapper for pusherapp.com REST api}
14
14
  s.email = %q{support@pusherapp.com}
15
15
  s.extra_rdoc_files = [
@@ -15,7 +15,7 @@ describe Authentication do
15
15
 
16
16
  it "should generate base64 encoded signature from correct key" do
17
17
  @request.send(:string_to_sign).should == "POST\n/some/path\nauth_key=key&auth_timestamp=1234&auth_version=1.0&go=here&query=params"
18
- @signature.should == 'OyN5U6W6ZhmHXLsqLUPo2p71gk6KLGifYoSshbweoNs='
18
+ @signature.should == '3b237953a5ba6619875cbb2a2d43e8da9ef5824e8a2c689f6284ac85bc1ea0db'
19
19
  end
20
20
 
21
21
  it "should make auth_hash available after request is signed" do
@@ -28,7 +28,7 @@ describe Authentication do
28
28
 
29
29
  request.sign(@token)
30
30
  request.auth_hash.should == {
31
- :auth_signature => "2gePzt1ylBtshzyqQNDWsgAOv8cAzugCsSjdIPcudOk=",
31
+ :auth_signature => "da078fcedd72941b6c873caa40d0d6b2000ebfc700cee802b128dd20f72e74e9",
32
32
  :auth_version => "1.0",
33
33
  :auth_key => "key",
34
34
  :auth_timestamp => 1234
@@ -88,7 +88,7 @@ describe Authentication do
88
88
  request = Authentication::Request.new('POST', '/some/path', @params)
89
89
  lambda {
90
90
  request.authenticate_by_token!(@token)
91
- }.should raise_error('Invalid signature: you should have sent Base64Encode(HmacSHA256("POST\n/some/path\nauth_key=key&auth_timestamp=1234&auth_version=1.0&go=here&query=params", your_secret_key))')
91
+ }.should raise_error('Invalid signature: you should have sent HmacSHA256Hex("POST\n/some/path\nauth_key=key&auth_timestamp=1234&auth_version=1.0&go=here&query=params", your_secret_key)')
92
92
  end
93
93
 
94
94
  it "should raise error if timestamp not available" do
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 4
8
8
  - 0
9
9
  - beta
10
- - 1
11
- version: 0.4.0.beta.1
10
+ - 2
11
+ version: 0.4.0.beta.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - New Bamboo
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-22 00:00:00 +01:00
19
+ date: 2010-04-23 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency