smaak 0.1.6 → 0.1.8
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/README.md +8 -0
- data/lib/smaak/auth_message.rb +0 -1
- data/lib/smaak/server.rb +17 -4
- data/lib/smaak/version.rb +1 -1
- data/spec/lib/smaak/auth_message_spec.rb +0 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d73a7bae2454b5626a8a50fd7028c62cf071b0
|
4
|
+
data.tar.gz: e562fc1e85c951f86b4dedb8fbdcc9ebf17487c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4305d3436bea55aba4e63b131792edb6b6df5715a8537519703930f8774ceb74c878bdf5cb2a06345ad0e96f75879ebb7c40b49d368dab289219b2e05b90a910
|
7
|
+
data.tar.gz: a52f81b5f4a7b5dad3991bac7720c2af94cfffbf0bf791f101ca794f1cb5a78f96547158b9c06680920693276103d414f602cdbe2e68f58da4f68ea65052519e
|
data/README.md
CHANGED
@@ -12,6 +12,14 @@ The signing of an HTTP request and the placement of the signature in an Authoriz
|
|
12
12
|
|
13
13
|
Smaak verifies an AuthMessage signed in the Authorization header by looking at nonce, expiry, recipient and pre-shared key. The order of headers signed is important for signature verification.
|
14
14
|
|
15
|
+
### Requires
|
16
|
+
|
17
|
+
In order for smaak to utilize adaptors and technology you choose, ensure to require the necessary libraries. For example:
|
18
|
+
|
19
|
+
require 'rack'
|
20
|
+
require 'net'
|
21
|
+
require 'net/http'
|
22
|
+
|
15
23
|
### Example Server
|
16
24
|
|
17
25
|
A Smaak::Server operates on an instance of an HTTP request received. The Smaak module can be told about different request technology implementations by providing an adaptor to a request technology (Smaak::add_request_adaptor). The gem ships with a Rack::Request adaptor. Call Smaak::create_adaptor with your request to get an instance of an adaptor.
|
data/lib/smaak/auth_message.rb
CHANGED
data/lib/smaak/server.rb
CHANGED
@@ -39,15 +39,28 @@ module Smaak
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def verify_auth_message(auth_message)
|
42
|
-
|
43
|
-
|
42
|
+
if not auth_message_unique?(auth_message)
|
43
|
+
puts "[smaak error]: message not unique"
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
if not auth_message.intended_for_recipient?(@key.export)
|
47
|
+
puts "[smaak error]: message not unique"
|
48
|
+
return false
|
49
|
+
end
|
44
50
|
identifier = auth_message.identifier
|
45
51
|
if @association_store[identifier].nil?
|
46
|
-
puts "
|
52
|
+
puts "[smaak error]: unknown associate #{identifier}"
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
if auth_message.expired?
|
56
|
+
puts "[smaak error]: message expired. Are the sender and receiver's clocks in sync?"
|
47
57
|
return false
|
48
58
|
end
|
49
59
|
psk = @association_store[identifier]['psk']
|
50
|
-
|
60
|
+
if not auth_message.verify(psk)
|
61
|
+
puts "[smaak error]: PSK mismatch"
|
62
|
+
return false
|
63
|
+
end
|
51
64
|
true
|
52
65
|
end
|
53
66
|
|
data/lib/smaak/version.rb
CHANGED
@@ -132,11 +132,6 @@ describe Smaak::AuthMessage do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
context "when asked to verify the message" do
|
135
|
-
it "should check message expiry and return false if the message has expired" do
|
136
|
-
expect(@iut).to(receive(:expired?)).and_return(true)
|
137
|
-
expect(@iut.verify(Smaak::Crypto::obfuscate_psk(@test_psk))).to eq(false)
|
138
|
-
end
|
139
|
-
|
140
135
|
it "should try and match the PSK and return false if it cannot" do
|
141
136
|
expect(@iut).to(receive(:psk_match?)).and_return(false)
|
142
137
|
expect(@iut.verify(Smaak::Crypto::obfuscate_psk(@test_psk))).to eq(false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smaak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: persistent-cache
|