smaak 0.1.6 → 0.1.8

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: 6176a9640dcdb10ed78ac51b33d272cfcce6b4a8
4
- data.tar.gz: 0ccff319f89b625a988f4565a8d0d2bc9dc35d7f
3
+ metadata.gz: 01d73a7bae2454b5626a8a50fd7028c62cf071b0
4
+ data.tar.gz: e562fc1e85c951f86b4dedb8fbdcc9ebf17487c6
5
5
  SHA512:
6
- metadata.gz: 00b783a3d6db9dceb9f353b7c889a5bf595f6158d2594d13b87ac1a9dfddb57f8bbf47c754d19fc7b8f7908cee78e971e6affb451ed7adfd5ee99081e8796c96
7
- data.tar.gz: 706a6ad29291fd7327bce6b803fcd7bb20f61696f7121a899b9150c0a692b4b263cfba7248f951b9c00caf241644cc1b9acd4bd6a2dfb517b903eb2574efa1a1
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.
@@ -61,7 +61,6 @@ module Smaak
61
61
  end
62
62
 
63
63
  def verify(psk)
64
- return false if expired?
65
64
  return false if not psk_match?(psk)
66
65
  true
67
66
  end
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
- return false if not auth_message_unique?(auth_message)
43
- return false if not auth_message.intended_for_recipient?(@key.export)
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 "Unknown associate #{identifier}"
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
- return false if not auth_message.verify(psk)
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
@@ -1,3 +1,3 @@
1
1
  module Smaak
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -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.6
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-06 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: persistent-cache