hawk-auth 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/hawk/crypto.rb +3 -1
- data/lib/hawk/server.rb +1 -1
- data/lib/hawk/version.rb +1 -1
- data/spec/crypto_spec.rb +15 -1
- data/spec/support/shared_examples/authorization_header.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d874a8b74a69720adcdf65281bbde9dd3892c8
|
4
|
+
data.tar.gz: c67331ba45a9697578513357f1ea4597e535c849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 817f75507d91c6c71c1d7ea4f6d59f42e1685227f26a9eeeeeecae0cc12b509dcef68a62915691db62722c64e8741728e5a0a3d5acbf6bfeca0627ec21aaa699
|
7
|
+
data.tar.gz: 8841dea3b396bb232bee8e8ffe241a4ff18c253e6c65ae0fc8f880d3ec6ba3cbcce6aabfd4a4d75c2a7e10e0b72566f45fb4301d05b0de4c1b28707b4bd64dad
|
data/lib/hawk/crypto.rb
CHANGED
@@ -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
|
data/lib/hawk/server.rb
CHANGED
@@ -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
|
|
data/lib/hawk/version.rb
CHANGED
data/spec/crypto_spec.rb
CHANGED
@@ -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.
|
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:
|
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.
|
116
|
+
rubygems_version: 2.0.14
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Ruby implementation of Hawk
|