hawk-auth 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0520600ff04a5b34f08821c26c42350db21ee2b4
4
- data.tar.gz: 6bd61486e985287d0cc944595444f4f9012bc736
3
+ metadata.gz: 10d874a8b74a69720adcdf65281bbde9dd3892c8
4
+ data.tar.gz: c67331ba45a9697578513357f1ea4597e535c849
5
5
  SHA512:
6
- metadata.gz: 0b8136675219d0dfb65acb94022f5fc14b1b4595e61fe2391ecf8969b1e3fc0420b19b0c62ee52d54ad9de4650c8891c4c4a675704f0c2ccb3df244c281023e9
7
- data.tar.gz: 567bd2820b6a62f80337d37d1c45899d425e770030b060447b1cd92f25aadb06a2542815ef1604692390323ea2c75993eb3a1090a0ffe417efac3f1e5f7fbe80
6
+ metadata.gz: 817f75507d91c6c71c1d7ea4f6d59f42e1685227f26a9eeeeeecae0cc12b509dcef68a62915691db62722c64e8741728e5a0a3d5acbf6bfeca0627ec21aaa699
7
+ data.tar.gz: 8841dea3b396bb232bee8e8ffe241a4ff18c253e6c65ae0fc8f880d3ec6ba3cbcce6aabfd4a4d75c2a7e10e0b72566f45fb4301d05b0de4c1b28707b4bd64dad
@@ -40,7 +40,7 @@ module Hawk
40
40
  secure_compare(to_s(:raw => true), other.to_s(:raw => true))
41
41
  else
42
42
  # assume base64 encoded mac
43
- secure_compare(to_s(:raw => true), Base64.decode64(other))
43
+ secure_compare(to_s(:raw => true), Base64.decode64(other.to_s))
44
44
  end
45
45
  end
46
46
 
@@ -105,6 +105,8 @@ module Hawk
105
105
  class Hash < Base
106
106
  def initialize(content_type, payload, algorithm)
107
107
  @content_type, @payload, @algorithm = content_type, payload, algorithm
108
+
109
+ @content_type = @content_type.to_s.split(';').first.to_s.sub(/\A\s*/, '').sub(/\s*\Z/, '')
108
110
  end
109
111
 
110
112
  def normalized_string
@@ -33,7 +33,7 @@ module Hawk
33
33
  :request_uri => options[:request_uri].sub(%r{\Ahttps?://[^/]+}, '')
34
34
  ))
35
35
  else
36
- return AuthenticationFailure.new(:bewit, "Invalid signature")
36
+ return AuthenticationFailure.new(:bewit, "Invalid signature #{expected_bewit.mac.normalized_string}")
37
37
  end
38
38
  end
39
39
 
@@ -1,3 +1,3 @@
1
1
  module Hawk
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -16,7 +16,7 @@ describe Hawk::Crypto do
16
16
 
17
17
  shared_examples "a payload hashing method" do
18
18
  it "returns valid base64 encoded hash of payload" do
19
- expect(described_class.send(hashing_method, input)).to eql(expected_output)
19
+ expect(described_class.send(hashing_method, input).to_s).to eql(expected_output)
20
20
  end
21
21
  end
22
22
 
@@ -45,6 +45,20 @@ describe Hawk::Crypto do
45
45
  let(:expected_output) { "LjRmtkSKTW0ObTUyZ7N+vjClKd//KTTdfhF1M4XCuEM=" }
46
46
 
47
47
  it_behaves_like "a payload hashing method"
48
+
49
+ context "when Content-Type has parameters" do
50
+ let(:input) do
51
+ {
52
+ :credentials => credentials,
53
+ :content_type => ' text/plain ; type="something"',
54
+ :payload => 'Something to write about',
55
+ }
56
+ end
57
+
58
+ let(:expected_output) { "RBzsyF5kNxkvMWvOKj90ULW1LHqOwqRo1sAEjjUkPuo=" }
59
+
60
+ it_behaves_like "a payload hashing method"
61
+ end
48
62
  end
49
63
  end
50
64
 
@@ -149,6 +149,16 @@ shared_examples "an authorization header authenticator" do
149
149
  expect(actual.message).to_not eql(nil)
150
150
  end
151
151
  end
152
+
153
+ context "when empty header" do
154
+ let(:authorization_header) { "" }
155
+
156
+ it "returns an error object" do
157
+ actual = described_class.authenticate(authorization_header, input)
158
+ expect(actual).to be_a(Hawk::AuthenticationFailure)
159
+ expect(actual.message).to_not eql(nil)
160
+ end
161
+ end
152
162
  end
153
163
  end
154
164
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hawk-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Stuart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.0.7
116
+ rubygems_version: 2.0.14
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Ruby implementation of Hawk