smaak 0.1.17 → 0.2.0

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: f45f06921b628e88bdca56b549ece83df6ec865c
4
- data.tar.gz: 2e1c446e1f3f3eed67162ca298e8ad88dc75d000
3
+ metadata.gz: 685bcd7d6219373c53cb4b6e64391a810b75c9b7
4
+ data.tar.gz: 2388377ec73aa7a30a3c5149669092865a22342c
5
5
  SHA512:
6
- metadata.gz: 99d952eb0657697c4247f6d5fc1c4fb0e37ce320d31fa8ad483e008becd1958a05225cd7bbd64ed004d2e19d1df16faccd5ea80b835497e920dbdeb19f50cb0a
7
- data.tar.gz: 95b53689765041860e3dcb3b5a652fb98409facf274596ce88c06fc74f897813140e134391209983268f11ea843542d907fa1ed66da0add5b8ecb6332b0d447d
6
+ metadata.gz: 12e5a7872bf97d282c4fd918eabaf763ff73eae95b8320bd108f3cf8e8eeab77d3c9b314330533b52a3e3d8f1080ef9c560fc0d0019f2aa77f82c7e71cc93fa2
7
+ data.tar.gz: 10b54cceaed0fb18133d9650627557bf120a3ff4b0bbabf97645f84cb90b6bb8896fbb0369fec9ac0a2644fc604ae0d7daf32a995138672d7ef0855b5c4528d3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smaak
2
2
 
3
- This gems caters for both client and server sides of a signed message interaction over HTTP implementing RFC2617 Digest Access Authentication as well as IETF draft-cavage-http-signatures-04, extended with 'x-smaak-recipient', 'x-smaak-identifier', 'x-smaak-psk', 'x-smaak-expires' and 'x-smaak-nonce' headers. The following compromises are protected against as specified: Man in the middle (header and payload signature, as well as body digest) / snooping (message body encryption), Replay (nonce + expiry), Forgery (signature), Masquerading (identifier and signature), Forwarding / Unintended recipient (recipient pub key check), Clear-text password compromise (MD5 pre-shared key, obfuscated), lack of password (pre-shared key), Message fabrication (associations are purpose-fully provisioned to known associates.)
3
+ This gems caters for both client and server sides of a signed message interaction over HTTP implementing RFC2617 Digest Access Authentication as well as IETF draft-cavage-http-signatures-04, extended with 'x-smaak-recipient', 'x-smaak-identifier', 'x-smaak-route-info', 'x-smaak-psk', 'x-smaak-expires' and 'x-smaak-nonce' headers. The following compromises are protected against as specified: Man in the middle (header and payload signature, as well as body digest) / snooping (message body encryption), Replay (nonce + expiry), Forgery (signature), Masquerading (identifier and signature), Forwarding / Unintended recipient (recipient pub key check), Clear-text password compromise (MD5 pre-shared key, obfuscated), lack of password (pre-shared key), Message fabrication (associations are purpose-fully provisioned to known associates.)
4
4
 
5
5
  ## Smaak mechanism
6
6
 
@@ -84,6 +84,8 @@ A Smaak::Client operates on an instance of an HTTP request. The Smaak module can
84
84
 
85
85
  During provisioning, we recommend that the key-pair that does the signing and verification has associated with it an X.509 certificate signed by a CA you trust that contains the identity of the signer. The association is provisioned with an 'identifier' that the Authorization header transports in the 'x-smaak-identifier' header. This identifier is used on the receiver end to look up the public key of the signer in the association list. Once the associated key successfully verifies the signature, that certificate's identity can be used for identity management and authorization. This allows multiple identifiers (e.g. multiple server heads) to represent a single service (identity) with separate signing certs for each head.
86
86
 
87
+ As an additional optional identifying header, x-smaak-rout-info can be utilized (e.g. in cases where x-smaak-identifier is a bus identifier and there is a need to also identify the entity that engaged on the bus)
88
+
87
89
  ## Example on-the-wire requests
88
90
 
89
91
  ### Un-encrypted
@@ -98,6 +100,7 @@ During provisioning, we recommend that the key-pair that does the signing and ve
98
100
  Digest: SHA-256=0190f465c943501984c4018bacdbb0be167979f261caf1fe50ce63e97d31dff2
99
101
  X-Smaak-Recipient: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxL2tiYjdBNWllQWV1WlBBVnI3MAo5cjl1TkFzc2dmYkdjeGMzZTc3RDNndkY4U2tzbURNQmQyTUt5TUh0ZjBrM1pqSVdZemJJVG5jQXM1Nnd4cmRSClhiVHpIZnhjMll1dDMwd0ljR2YvUVk4ZTJXNmdMWko4aVM3MXlYb0JQNFpEc2lLSXd4ajFsenYyVFlXWnNSL3EKd28xSzBxZ1NzOXJJVEVkWDVqampycHBYWTdobHNPMGVKQ2JBRG0weEtnU1hMcFQycnJzUnJ2OFllRXFvZTRMaQpDOFd6RjZZRlh1U3RHR1E4SXlxbjdPaTN5aVU2WFc3OTl2cFpIeHJlaERYaytDalZuU0ZXWkVPUHg3cENpam9SCnlXb0gyUmR6QVpQczdVdVJWOUdGWWFQeHRudmttNVdVZDVTdWVCNlMxT2E4dVZ3UnpyeXl6WkRjdG0xdWs1VjIKUE0zLzFqbFJMbFJzTWxSeHdZUDRzaFMzVlhjTkdGYjkvbzkvTjkzbitKZUFpSGd4YU5pQjN6YVV0a05XWWs0Vgozang2d0psTythOUNxdGJJeXg2ZzdyTHhOanVqRFpRZTZGcUdsMzVkVDR5MHA2UmVuUWQ4b1p5aWw3dlpqSkJaCjluTWRJblMyU05wWUZFclBsb25rdXNZKzZsam9TbFNLMXVSRmd2S3dzeGE3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
100
102
  X-Smaak-Identifier: service-provider-public
103
+ X-Smaak-Route-Info:
101
104
  X-Smaak-Psk: 917e5f9bcf6d7c20a338d8a39bbf79ef
102
105
  X-Smaak-Expires: 1435225695
103
106
  X-Smaak-Nonce: 7211840395
@@ -118,6 +121,7 @@ During provisioning, we recommend that the key-pair that does the signing and ve
118
121
  Digest: SHA-256=3f4502e658dd304d4cd1004a83935ede11692751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Q0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
120
123
  X-Smaak-Identifier: service-provider-public
124
+ X-Smaak-Route-Info:
121
125
  X-Smaak-Psk: 917e5f9bcf6d7c20a338d8a39bbf79ef
122
126
  X-Smaak-Expires: 1435225536
123
127
  X-Smaak-Nonce: 1443964335
data/lib/smaak.rb CHANGED
@@ -15,6 +15,7 @@ module Smaak
15
15
  def self.headers_to_be_signed
16
16
  [ "x-smaak-recipient",
17
17
  "x-smaak-identifier",
18
+ "x-smaak-route-info",
18
19
  "x-smaak-psk",
19
20
  "x-smaak-expires",
20
21
  "x-smaak-nonce",
@@ -3,29 +3,34 @@ require 'smaak/crypto'
3
3
  module Smaak
4
4
  class AuthMessage
5
5
  attr_reader :identifier
6
+ attr_reader :route_info
6
7
  attr_reader :nonce
7
8
  attr_reader :recipient
8
9
  attr_reader :psk
9
10
  attr_reader :expires
10
11
  attr_reader :encrypt
11
12
 
12
- def self.create(recipient_public_key, psk, token_life, identifier, encrypt = false)
13
+ def self.create(recipient_public_key, psk, token_life, identifier, route_info = "", encrypt = false)
13
14
  nonce = Smaak::Crypto::generate_nonce
14
15
  expires = Time.now.to_i + token_life
15
16
  #Must obfuscate PSK. AuthMessage must always have an obfuscated PSK
16
17
  psk = Smaak::Crypto::obfuscate_psk(psk)
17
- AuthMessage::build(recipient_public_key, psk, expires, identifier, nonce, encrypt)
18
+ AuthMessage::build(recipient_public_key, psk, expires, identifier, route_info, nonce, encrypt)
18
19
  end
19
20
 
20
- def self.build(recipient_public_key, psk, expires, identifier, nonce, encrypt = false)
21
+ def self.build(recipient_public_key, psk, expires, identifier, route_info, nonce, encrypt = false)
21
22
  #No need to obfuscate PSK. Off the wire we should always expect an obfuscated PSK
22
- AuthMessage.new(identifier, nonce, expires, psk, recipient_public_key, encrypt)
23
+ AuthMessage.new(identifier, route_info, nonce, expires, psk, recipient_public_key, encrypt)
23
24
  end
24
25
 
25
- def initialize(identifier, nonce, expires, psk, recipient_public_key, encrypt)
26
- raise ArgumentError.new("Message must have a valid identifier set") if identifier.nil? or identifier.empty?
26
+ def initialize(identifier, route_info, nonce, expires, psk, recipient_public_key, encrypt)
27
+ raise ArgumentError.new("Message must have a valid identifier set") if identifier.nil? or identifier.empty?
28
+ raise ArgumentError.new("Message must have a valid route information set") if route_info.nil?
27
29
  @identifier = identifier
28
30
  @identifier.freeze
31
+ @route_info = route_info
32
+
33
+ @route_info.freeze
29
34
 
30
35
  raise ArgumentError.new("Message must have a valid nonce set") if not validate_nonce(nonce)
31
36
  @nonce = nonce
@@ -38,6 +38,7 @@ module Smaak
38
38
  @adaptor.set_header("digest", "SHA-256=#{Digest::SHA256.hexdigest(body)}")
39
39
  @adaptor.set_header("x-smaak-recipient", "#{Smaak::Crypto::encode64(auth_message.recipient)}")
40
40
  @adaptor.set_header("x-smaak-identifier", "#{auth_message.identifier}")
41
+ @adaptor.set_header("x-smaak-route-info", "#{auth_message.route_info}")
41
42
  @adaptor.set_header("x-smaak-psk", "#{auth_message.psk}")
42
43
  @adaptor.set_header("x-smaak-expires", "#{auth_message.expires}")
43
44
  @adaptor.set_header("x-smaak-nonce", "#{auth_message.nonce}")
data/lib/smaak/client.rb CHANGED
@@ -6,6 +6,12 @@ require 'smaak/auth_message.rb'
6
6
  module Smaak
7
7
  class Client < Associate
8
8
  attr_reader :identifier
9
+ attr_reader :route_info
10
+
11
+ def initialize
12
+ super
13
+ set_route_info("")
14
+ end
9
15
 
10
16
  def set_private_key(key)
11
17
  set_key(key)
@@ -16,11 +22,16 @@ module Smaak
16
22
  @identifier = identifier
17
23
  end
18
24
 
25
+ def set_route_info(route_info)
26
+ @route_info = route_info
27
+ @route_info ||= ""
28
+ end
29
+
19
30
  def sign_request(associate_identifier, adaptor)
20
31
  raise ArgumentError.new("Associate invalid") if not validate_associate(associate_identifier)
21
32
  associate = @association_store[associate_identifier]
22
33
  raise ArgumentError.new("Invalid adaptor") if adaptor.nil?
23
- auth_message = Smaak::AuthMessage.create(associate['public_key'].export, associate['psk'], @token_life, @identifier, associate['encrypt'])
34
+ auth_message = Smaak::AuthMessage.create(associate['public_key'].export, associate['psk'], @token_life, @identifier, @route_info, associate['encrypt'])
24
35
  adaptor.body = Smaak::Crypto::encrypt(adaptor.body, associate['public_key']) if auth_message.encrypt
25
36
  adaptor = Smaak::sign_authorization_headers(@key, auth_message, adaptor, Smaak::Cavage04::SPECIFICATION)
26
37
  end
data/lib/smaak/server.rb CHANGED
@@ -36,9 +36,10 @@ module Smaak
36
36
  psk = adaptor.header("x-smaak-psk")
37
37
  expires = adaptor.header("x-smaak-expires")
38
38
  identifier = adaptor.header("x-smaak-identifier")
39
+ route_info = adaptor.header("x-smaak-route-info")
39
40
  nonce = adaptor.header("x-smaak-nonce")
40
41
  encrypt = adaptor.header("x-smaak-encrypt")
41
- auth_message = Smaak::AuthMessage.build(recipient_public_key, psk, expires, identifier, nonce, encrypt)
42
+ auth_message = Smaak::AuthMessage.build(recipient_public_key, psk, expires, identifier, route_info, nonce, encrypt)
42
43
  end
43
44
 
44
45
  def verify_auth_message(auth_message)
data/lib/smaak/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Smaak
2
- VERSION = "0.1.17"
2
+ VERSION = "0.2.0"
3
3
  end
data/smaak.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "persistent-cache-ram"
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
- #spec.add_development_dependency "byebug"
25
+ # spec.add_development_dependency "byebug"
26
26
  spec.add_development_dependency 'simplecov'
27
27
  spec.add_development_dependency 'simplecov-rcov'
28
28
  spec.add_development_dependency 'rspec'
@@ -10,49 +10,56 @@ describe Smaak::AuthMessage do
10
10
  @test_server_public_key = @test_server_private_key.public_key
11
11
  @test_identity = "test-service"
12
12
  @test_identifier = 'test-service-1.cpt1.host-h.net'
13
+ @test_route_info = 'identifier'
13
14
  @test_recipient = @test_server_public_key.export
14
15
  @test_encrypt = true
15
16
  end
16
17
 
17
18
  before :each do
18
19
  @test_expires = Time.now.to_i + @test_token_life
19
- @iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
20
+ @iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
20
21
  end
21
22
 
22
23
  context "when initialized" do
23
24
  it "should raise an ArgumentError if no identifier is provided" do
24
25
  expect {
25
- Smaak::AuthMessage.new(nil, nil, nil, nil, nil, nil)
26
+ Smaak::AuthMessage.new(nil, @test_route_info, nil, nil, nil, nil, nil)
26
27
  }.to raise_error ArgumentError, "Message must have a valid identifier set"
27
28
  end
28
29
 
30
+ it "should raise an ArgumentError if no route information is provided" do
31
+ expect {
32
+ Smaak::AuthMessage.new(@test_identifier, nil, nil, nil, nil, nil, nil)
33
+ }.to raise_error ArgumentError, "Message must have a valid route information set"
34
+ end
35
+
29
36
  it "should raise an ArgumentError if no nonce is provided" do
30
37
  expect {
31
- Smaak::AuthMessage.new(@test_identifier, nil, nil, nil, nil, nil)
38
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, nil, nil, nil, nil, nil)
32
39
  }.to raise_error ArgumentError, "Message must have a valid nonce set"
33
40
  end
34
41
 
35
42
  it "should raise an ArgumentError if an invalid nonce is provided" do
36
43
  expect {
37
- Smaak::AuthMessage.new(@test_identifier, 0, nil, nil, nil, nil)
44
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, 0, nil, nil, nil, nil)
38
45
  }.to raise_error ArgumentError, "Message must have a valid nonce set"
39
46
  expect {
40
- Smaak::AuthMessage.new(@test_identifier, 'invalid nonce', nil, nil, nil, nil)
47
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, 'invalid nonce', nil, nil, nil, nil)
41
48
  }.to raise_error ArgumentError, "Message must have a valid nonce set"
42
49
  end
43
50
 
44
51
  it "should raise an ArgumentError if no expiry is provided" do
45
52
  expect {
46
- Smaak::AuthMessage.new(@test_identifier, @test_nonce, nil, nil, nil, nil)
53
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, nil, nil, nil, nil)
47
54
  }.to raise_error ArgumentError, "Message must have a valid expiry set"
48
55
  end
49
56
 
50
57
  it "should raise an ArgumentError if an invalid expiry is provided" do
51
58
  expect {
52
- Smaak::AuthMessage.new(@test_identifier, @test_nonce, 0, nil, nil, nil)
59
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, 0, nil, nil, nil)
53
60
  }.to raise_error ArgumentError, "Message must have a valid expiry set"
54
61
  expect {
55
- Smaak::AuthMessage.new(@test_identifier, @test_nonce, 'invalid expire', nil, nil, nil)
62
+ Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, 'invalid expire', nil, nil, nil)
56
63
  }.to raise_error ArgumentError, "Message must have a valid expiry set"
57
64
  end
58
65
 
@@ -81,23 +88,23 @@ describe Smaak::AuthMessage do
81
88
  end
82
89
 
83
90
  it "should translate the encrypt parameter from string to boolean" do
84
- iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, false)
91
+ iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, false)
85
92
  expect(iut.encrypt).to eq(false)
86
93
 
87
- iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, true)
94
+ iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, true)
88
95
  expect(iut.encrypt).to eq(true)
89
96
 
90
- iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, "false")
97
+ iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, "false")
91
98
  expect(iut.encrypt).to eq(false)
92
99
 
93
- iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, "true")
100
+ iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, "true")
94
101
  expect(iut.encrypt).to eq(true)
95
102
  end
96
103
  end
97
104
 
98
105
  context "when asked if it has expired" do
99
106
  it "should return true if the current timestamp exceeds that of the message expiry" do
100
- iut = Smaak::AuthMessage.new(@test_identifier, @test_nonce, Time.now - 1, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, false)
107
+ iut = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, Time.now - 1, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, false)
101
108
  expect(iut.expired?).to eq(true)
102
109
  end
103
110
 
@@ -145,15 +152,15 @@ describe Smaak::AuthMessage do
145
152
  context "when asked to create an AuthMessage from scratch" do
146
153
  it "should initialize with the recipient_public_key, psk, expires, identifier, nonce, encrypt provided, calculating expiry, generating a nonce, and obfuscating the PSK" do
147
154
  allow(Smaak::Crypto).to receive(:generate_nonce).and_return(@test_nonce)
148
- expect(Smaak::AuthMessage).to receive(:new).with(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
149
- Smaak::AuthMessage.create(@test_recipient, @test_psk, @test_token_life, @test_identifier, @test_encrypt)
155
+ expect(Smaak::AuthMessage).to receive(:new).with(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
156
+ Smaak::AuthMessage.create(@test_recipient, @test_psk, @test_token_life, @test_identifier, @test_route_info, @test_encrypt)
150
157
  end
151
158
  end
152
159
 
153
160
  context "when asked to build an AuthMessage from existing data" do
154
161
  it "should initialize with the recipient_public_key, psk, expires, identifier, nonce, encrypt provided" do
155
- expect(Smaak::AuthMessage).to receive(:new).with(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
156
- Smaak::AuthMessage.build(@test_recipient, Smaak::Crypto::obfuscate_psk(@test_psk), @test_expires, @test_identifier, @test_nonce, @test_encrypt)
162
+ expect(Smaak::AuthMessage).to receive(:new).with(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
163
+ Smaak::AuthMessage.build(@test_recipient, Smaak::Crypto::obfuscate_psk(@test_psk), @test_expires, @test_identifier, @test_route_info, @test_nonce, @test_encrypt)
157
164
  end
158
165
  end
159
166
  end
@@ -18,9 +18,10 @@ describe Smaak::Cavage04 do
18
18
  @test_server_public_key = @test_server_private_key.public_key
19
19
  @test_identity = "test-service"
20
20
  @test_identifier = 'test-service-1.cpt1.host-h.net'
21
+ @test_route_info = 'identifier'
21
22
  @test_recipient = @test_server_public_key.export
22
23
  @test_encrypt = true
23
- @auth_message = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
24
+ @auth_message = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
24
25
  end
25
26
 
26
27
  context "as a specification implementation" do
@@ -177,11 +178,12 @@ describe Smaak::Cavage04 do
177
178
  expect(headers[3].split(":")[0]).to eql("digest")
178
179
  expect(headers[4].split(":")[0]).to eql("x-smaak-recipient")
179
180
  expect(headers[5].split(":")[0]).to eql("x-smaak-identifier")
180
- expect(headers[6].split(":")[0]).to eql("x-smaak-psk")
181
- expect(headers[7].split(":")[0]).to eql("x-smaak-expires")
182
- expect(headers[8].split(":")[0]).to eql("x-smaak-nonce")
183
- expect(headers[9].split(":")[0]).to eql("x-smaak-encrypt")
184
- expect(headers[10].split(":")[0]).to eql("content-length")
181
+ expect(headers[6].split(":")[0]).to eql("x-smaak-route-info")
182
+ expect(headers[7].split(":")[0]).to eql("x-smaak-psk")
183
+ expect(headers[8].split(":")[0]).to eql("x-smaak-expires")
184
+ expect(headers[9].split(":")[0]).to eql("x-smaak-nonce")
185
+ expect(headers[10].split(":")[0]).to eql("x-smaak-encrypt")
186
+ expect(headers[11].split(":")[0]).to eql("content-length")
185
187
  end
186
188
 
187
189
  it "should not include int he list of signature headers non-signature headers" do
@@ -198,7 +200,7 @@ describe Smaak::Cavage04 do
198
200
  context "when receiving a signed header" do
199
201
  before :each do
200
202
  @env = \
201
- {"CONTENT_LENGTH"=>"25", "CONTENT_TYPE"=>"text/plain", "GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/secure-service", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"10.0.0.224", "REMOTE_HOST"=>"service-provider-public", "REQUEST_METHOD"=>"POST", "REQUEST_URI"=>"http://service-provider-internal:9393/secure-service", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"service-provider-internal", "SERVER_PORT"=>"9393", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)", "HTTP_ACCEPT_ENCODING"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "HTTP_ACCEPT"=>"*/*", "HTTP_USER_AGENT"=>"Ruby", "HTTP_AUTHORIZATION"=>"Signature keyId=\"rsa-key-1\",algorithm=\"rsa-sha256\", headers=\"host date digest x-smaak-recipient x-smaak-identifier x-smaak-psk x-smaak-expires x-smaak-nonce x-smaak-encrypt content-length\", signature=\"RQgXQo+Fugz1ubgV1UAJvdPaNHiwTMtu0x+LNJ/7rvY5ga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c2lLSXd4ajFsenYyVFlXWnNSL3EKd28xSzBxZ1NzOXJJVEVkWDVqampycHBYWTdobHNPMGVKQ2JBRG0weEtnU1hMcFQycnJzUnJ2OFllRXFvZTRMaQpDOFd6RjZZRlh1U3RHR1E4SXlxbjdPaTN5aVU2WFc3OTl2cFpIeHJlaERYaytDalZuU0ZXWkVPUHg3cENpam9SCnlXb0gyUmR6QVpQczdVdVJWOUdGWWFQeHRudmttNVdVZDVTdWVCNlMxT2E4dVZ3UnpyeXl6WkRjdG0xdWs1VjIKUE0zLzFqbFJMbFJzTWxSeHdZUDRzaFMzVlhjTkdGYjkvbzkvTjkzbitKZUFpSGd4YU5pQjN6YVV0a05XWWs0Vgozang2d0psTythOUNxdGJJeXg2ZzdyTHhOanVqRFpRZTZGcUdsMzVkVDR5MHA2UmVuUWQ4b1p5aWw3dlpqSkJaCjluTWRJblMyU05wWUZFclBsb25rdXNZKzZsam9TbFNLMXVSRmd2S3dzeGE3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=", "HTTP_X_SMAAK_IDENTIFIER"=>"service-provider-public", "HTTP_X_SMAAK_PSK"=>"917e5f9bcf6d7c20a338d8a39bbf79ef", "HTTP_X_SMAAK_EXPIRES"=>"1435066809", "HTTP_X_SMAAK_NONCE"=>"6457661831", "HTTP_X_SMAAK_ENCRYPT"=>"false", "HTTP_CONNECTION"=>"close"}
203
+ {"CONTENT_LENGTH"=>"25", "CONTENT_TYPE"=>"text/plain", "GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/secure-service", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"10.0.0.224", "REMOTE_HOST"=>"service-provider-public", "REQUEST_METHOD"=>"POST", "REQUEST_URI"=>"http://service-provider-internal:9393/secure-service", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"service-provider-internal", "SERVER_PORT"=>"9393", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.0.0/2014-02-24)", "HTTP_ACCEPT_ENCODING"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "HTTP_ACCEPT"=>"*/*", "HTTP_USER_AGENT"=>"Ruby", "HTTP_AUTHORIZATION"=>"Signature keyId=\"rsa-key-1\",algorithm=\"rsa-sha256\", headers=\"host date digest x-smaak-recipient x-smaak-identifier x-smaak-route-info x-smaak-psk x-smaak-expires x-smaak-nonce x-smaak-encrypt content-length\", signature=\"RQgXQo+Fugz1ubgV1UAJvdPaNHiwTMtu0x+LNJ/7rvY5gaY5R88tUPtcFMzjRzw2QXtY5pettjfbq9LvISnW5MFG7p+goY4YsF4a6b7KgbU8RCAMLVyj4zWEIh/R+3WovuhcG8e5iLGN5/HGHkgDjZzi1a2WwU+tcwSwKBQ0BN+hKUV6haAHxUcNJ8bOgtnZZpSbD0megEmmBwiOjY5EsdM9wFMqGRrBWYV950xs/cPgO7Hjgq4kTnBiFC8Zkcz5zmkkokVE6VliNSPrqIZHm4fGk9UWyDYydlE+4z/wa4KrDs7/JXCQh+HF+BfSlnhG1xm9UT857o8Uz3j8ds4hvzUJyVcHX5B7wFln5szSFz5cdNFdMq6RP3e/TWGEV9J3sWi3pLymQog9jfkS1sjBSUxlc0Nh1hyiBFjybPZcbx6L77hsYV7dnCKF1z5UItvNj2JOkUCe+ppDkfhNxNkSUv9KBir+U+xJwDh+uyO/IAj8TB0cklsdnJNNHCDA4Mmi59RnA6uMsjOo6j7btkRF8nZmDvq0AWmgIUnwIWNWt13ecBH6u1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3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=", "HTTP_X_SMAAK_IDENTIFIER"=>"service-provider-public", "HTTP_X_SMAAK_ROUTE_INFO"=>"", "HTTP_X_SMAAK_PSK"=>"917e5f9bcf6d7c20a338d8a39bbf79ef", "HTTP_X_SMAAK_EXPIRES"=>"1435066809", "HTTP_X_SMAAK_NONCE"=>"6457661831", "HTTP_X_SMAAK_ENCRYPT"=>"false", "HTTP_CONNECTION"=>"close"}
202
204
  @request = Rack::Request.new(@env)
203
205
  @adaptor = Smaak::RackAdaptor.new(@request)
204
206
  @iut = Smaak::Cavage04.new(@adaptor)
@@ -207,7 +209,7 @@ describe Smaak::Cavage04 do
207
209
  context "when asked to extract signature headers from a request" do
208
210
  it "should find the signature headers list in the authorization header return them separated using spaces" do
209
211
  expect(@iut.extract_signature_headers).to eq(\
210
- "(request-target): post /secure-service\nhost: service-provider-internal\ndate: 2015-06-23 13:40:07 GMT\ndigest: SHA-256=748957b58cc24d2bb9eb8f9c468571712a14f6a89ce936c0fb2d3c5016e4dbdc\nx-smaak-recipient: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxL2tiYjdBNWllQWV1WlBBVnI3MAo5cjl1TkFzc2dmYkdjeGMzZTc3RDNndkY4U2tzbURNQmQyTUt5TUh0ZjBrM1pqSVdZemJJVG5jQXM1Nnd4cmRSClhiVHpIZnhjMll1dDMwd0ljR2YvUVk4ZTJXNmdMWko4aVM3MXlYb0JQNFpEc2lLSXd4ajFsenYyVFlXWnNSL3EKd28xSzBxZ1NzOXJJVEVkWDVqampycHBYWTdobHNPMGVKQ2JBRG0weEtnU1hMcFQycnJzUnJ2OFllRXFvZTRMaQpDOFd6RjZZRlh1U3RHR1E4SXlxbjdPaTN5aVU2WFc3OTl2cFpIeHJlaERYaytDalZuU0ZXWkVPUHg3cENpam9SCnlXb0gyUmR6QVpQczdVdVJWOUdGWWFQeHRudmttNVdVZDVTdWVCNlMxT2E4dVZ3UnpyeXl6WkRjdG0xdWs1VjIKUE0zLzFqbFJMbFJzTWxSeHdZUDRzaFMzVlhjTkdGYjkvbzkvTjkzbitKZUFpSGd4YU5pQjN6YVV0a05XWWs0Vgozang2d0psTythOUNxdGJJeXg2ZzdyTHhOanVqRFpRZTZGcUdsMzVkVDR5MHA2UmVuUWQ4b1p5aWw3dlpqSkJaCjluTWRJblMyU05wWUZFclBsb25rdXNZKzZsam9TbFNLMXVSRmd2S3dzeGE3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=\nx-smaak-identifier: service-provider-public\nx-smaak-psk: 917e5f9bcf6d7c20a338d8a39bbf79ef\nx-smaak-expires: 1435066809\nx-smaak-nonce: 6457661831\nx-smaak-encrypt: false\ncontent-length: 25")
212
+ "(request-target): post /secure-service\nhost: service-provider-internal\ndate: 2015-06-23 13:40:07 GMT\ndigest: SHA-256=748957b58cc24d2bb9eb8f9c468571712a14f6a89ce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0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=\nx-smaak-identifier: service-provider-public\nx-smaak-route-info: \nx-smaak-psk: 917e5f9bcf6d7c20a338d8a39bbf79ef\nx-smaak-expires: 1435066809\nx-smaak-nonce: 6457661831\nx-smaak-encrypt: false\ncontent-length: 25")
211
213
  end
212
214
 
213
215
  it "should prepend the (request-target) header" do
@@ -215,9 +217,9 @@ describe Smaak::Cavage04 do
215
217
  end
216
218
 
217
219
  it "should return the signature headers in the order expressed in the signature, so that signature verification can succeed" do
218
- #host date digest x-smaak-recipient x-smaak-identifier x-smaak-psk x-smaak-expires x-smaak-nonce x-smaak-encrypt content-length
220
+ #host date digest x-smaak-recipient x-smaak-identifier x-smaak-route-info x-smaak-psk x-smaak-expires x-smaak-nonce x-smaak-encrypt content-length
219
221
  expect(@iut.extract_signature_headers).to eq(\
220
- "(request-target): post /secure-service\nhost: service-provider-internal\ndate: 2015-06-23 13:40:07 GMT\ndigest: SHA-256=748957b58cc24d2bb9eb8f9c468571712a14f6a89ce936c0fb2d3c5016e4dbdc\nx-smaak-recipient: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxL2tiYjdBNWllQWV1WlBBVnI3MAo5cjl1TkFzc2dmYkdjeGMzZTc3RDNndkY4U2tzbURNQmQyTUt5TUh0ZjBrM1pqSVdZemJJVG5jQXM1Nnd4cmRSClhiVHpIZnhjMll1dDMwd0ljR2YvUVk4ZTJXNmdMWko4aVM3MXlYb0JQNFpEc2lLSXd4ajFsenYyVFlXWnNSL3EKd28xSzBxZ1NzOXJJVEVkWDVqampycHBYWTdobHNPMGVKQ2JBRG0weEtnU1hMcFQycnJzUnJ2OFllRXFvZTRMaQpDOFd6RjZZRlh1U3RHR1E4SXlxbjdPaTN5aVU2WFc3OTl2cFpIeHJlaERYaytDalZuU0ZXWkVPUHg3cENpam9SCnlXb0gyUmR6QVpQczdVdVJWOUdGWWFQeHRudmttNVdVZDVTdWVCNlMxT2E4dVZ3UnpyeXl6WkRjdG0xdWs1VjIKUE0zLzFqbFJMbFJzTWxSeHdZUDRzaFMzVlhjTkdGYjkvbzkvTjkzbitKZUFpSGd4YU5pQjN6YVV0a05XWWs0Vgozang2d0psTythOUNxdGJJeXg2ZzdyTHhOanVqRFpRZTZGcUdsMzVkVDR5MHA2UmVuUWQ4b1p5aWw3dlpqSkJaCjluTWRJblMyU05wWUZFclBsb25rdXNZKzZsam9TbFNLMXVSRmd2S3dzeGE3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=\nx-smaak-identifier: service-provider-public\nx-smaak-psk: 917e5f9bcf6d7c20a338d8a39bbf79ef\nx-smaak-expires: 1435066809\nx-smaak-nonce: 6457661831\nx-smaak-encrypt: false\ncontent-length: 25")
222
+ "(request-target): post /secure-service\nhost: service-provider-internal\ndate: 2015-06-23 13:40:07 GMT\ndigest: SHA-256=748957b58cc24d2bb9eb8f9c468571712a14f6a89ce936c0fb2d3c5016e4dbdc\nx-smaak-recipient: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxL2tiYjdBNWllQWV1WlBBVnI3MAo5cjl1TkFzc2dmYkdjeGMzZTc3RDNndkY4U2tzbURNQmQyTUt5TUh0ZjBrM1pqSVdZemJJVG5jQXM1Nnd4cmRSClhiVHpIZnhjMll1dDMwd0ljR2YvUVk4ZTJXNmdMWko4aVM3MXlYb0JQNFpEc2lLSXd4ajFsenYyVFlXWnNSL3EKd28xSzBxZ1NzOXJJVEVkWDVqampycHBYWTdobHNPMGVKQ2JBRG0weEtnU1hMcFQycnJzUnJ2OFllRXFvZTRMaQpDOFd6RjZZRlh1U3RHR1E4SXlxbjdPaTN5aVU2WFc3OTl2cFpIeHJlaERYaytDalZuU0ZXWkVPUHg3cENpam9SCnlXb0gyUmR6QVpQczdVdVJWOUdGWWFQeHRudmttNVdVZDVTdWVCNlMxT2E4dVZ3UnpyeXl6WkRjdG0xdWs1VjIKUE0zLzFqbFJMbFJzTWxSeHdZUDRzaFMzVlhjTkdGYjkvbzkvTjkzbitKZUFpSGd4YU5pQjN6YVV0a05XWWs0Vgozang2d0psTythOUNxdGJJeXg2ZzdyTHhOanVqRFpRZTZGcUdsMzVkVDR5MHA2UmVuUWQ4b1p5aWw3dlpqSkJaCjluTWRJblMyU05wWUZFclBsb25rdXNZKzZsam9TbFNLMXVSRmd2S3dzeGE3RmROMXZWSnRJQk9qdVJzSk9DaHYKOTB2K0ZEQWwxSnNZVUNPUnByUmtMWXB2TWI4Q1BZaUlzb3JmTUdKNnI3NktYUEIzRS9xejRmaWJ1UmZVeWJxMgp5eGxRTVJKb216d1BPemUrbWRQUU5Hd3VTTjU0VnByYXhoNGFpcWtaUVBsSWpRb1dFaFVKRWxMb0NtQXZ4TmtxCmRBcVZJMXZ3cS9FRXFBTEh3amJKRXIwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=\nx-smaak-identifier: service-provider-public\nx-smaak-route-info: \nx-smaak-psk: 917e5f9bcf6d7c20a338d8a39bbf79ef\nx-smaak-expires: 1435066809\nx-smaak-nonce: 6457661831\nx-smaak-encrypt: false\ncontent-length: 25")
221
223
  end
222
224
  end
223
225
 
@@ -13,6 +13,7 @@ describe Smaak::Client do
13
13
  @test_data = {}
14
14
  @iut = Smaak::Client.new
15
15
  @test_identifier = 'test-client-1.cpt1.host-h.net'
16
+ @test_route_info = 'identifier'
16
17
  @test_token_life = 5
17
18
  @iut.set_identifier(@test_identifier)
18
19
  @iut.set_private_key(@test_client_private_key)
@@ -45,6 +46,30 @@ describe Smaak::Client do
45
46
  end
46
47
  end
47
48
 
49
+ context "when given an route information" do
50
+ it "should remember a the route information provided" do
51
+ iut = Smaak::Client.new
52
+ expect(iut.route_info).to eq("")
53
+ iut.set_route_info(@test_route_info)
54
+ expect(iut.route_info).to eq(@test_route_info)
55
+ end
56
+ end
57
+
58
+ context "when given no route information" do
59
+ it "should remember empty route information" do
60
+ iut = Smaak::Client.new
61
+ iut.set_route_info(nil)
62
+ expect(iut.route_info).to eq("")
63
+ end
64
+ end
65
+
66
+ context "when initialized" do
67
+ it "should have empty route information" do
68
+ iut = Smaak::Client.new
69
+ expect(iut.route_info).to eq("")
70
+ end
71
+ end
72
+
48
73
  context "when asked to sign a request destined for an associate" do
49
74
  it "should raise an ArgumentError if the associate is unknown" do
50
75
  expect{
@@ -62,8 +87,9 @@ describe Smaak::Client do
62
87
  end
63
88
 
64
89
  it "should create a new auth message using the associate details" do
65
- expect(Smaak::AuthMessage).to receive(:create).with(@test_service_public_key.export, @test_service_psk, @test_token_life, @test_identifier, @test_encrypt)
90
+ expect(Smaak::AuthMessage).to receive(:create).with(@test_service_public_key.export, @test_service_psk, @test_token_life, @test_identifier, @test_route_info, @test_encrypt)
66
91
  expect {
92
+ @iut.set_route_info(@test_route_info)
67
93
  @iut.sign_request(@test_service_identifier, @test_adaptor)
68
94
  }.to raise_error NoMethodError
69
95
  end
@@ -17,7 +17,8 @@ describe Smaak::Server do
17
17
  @test_psk = "testpresharedkey"
18
18
  @test_server_public_key = @test_server_private_key.public_key
19
19
  @test_identifier = 'test-service-1.cpt1.host-h.net'
20
- @message = Smaak::AuthMessage.new(@test_identifier, @test_nonce, Time.now.to_i, @test_psk, @test_server_public_key.export, false)
20
+ @test_route_info = 'identifier'
21
+ @message = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, Time.now.to_i, @test_psk, @test_server_public_key.export, false)
21
22
  @iut.add_association(@test_identifier, @test_server_public_key, @test_psk, false)
22
23
  @iut.set_public_key(@test_server_public_key)
23
24
  @iut.set_private_key(@test_server_private_key)
@@ -28,7 +29,7 @@ describe Smaak::Server do
28
29
  expect(@iut.nonce_store[@test_nonce]).to eq(nil)
29
30
 
30
31
  @test_expires = "#{Time.now.to_i + 5}"
31
- @env = {"CONTENT_LENGTH" => "25", "REQUEST_METHOD" => "POST", "PATH_INFO" => "/gems/smaak", "HTTP_X_SMAAK_ENCRYPT" => "false", "HTTP_X_SMAAK_RECIPIENT" => Base64.strict_encode64(@test_server_public_key.export), "HTTP_X_SMAAK_IDENTIFIER" => @test_identifier, "HTTP_X_SMAAK_NONCE" => @test_nonce, "HTTP_X_SMAAK_EXPIRES" => @test_expires, "HTTP_X_SMAAK_PSK" => Smaak::Crypto::obfuscate_psk(@test_psk) }
32
+ @env = {"CONTENT_LENGTH" => "25", "REQUEST_METHOD" => "POST", "PATH_INFO" => "/gems/smaak", "HTTP_X_SMAAK_ENCRYPT" => "false", "HTTP_X_SMAAK_RECIPIENT" => Base64.strict_encode64(@test_server_public_key.export), "HTTP_X_SMAAK_IDENTIFIER" => @test_identifier, "HTTP_X_SMAAK_ROUTE_INFO" => @test_route_info, "HTTP_X_SMAAK_NONCE" => @test_nonce, "HTTP_X_SMAAK_EXPIRES" => @test_expires, "HTTP_X_SMAAK_PSK" => Smaak::Crypto::obfuscate_psk(@test_psk) }
32
33
  @auth_message = mock_auth_message(@env)
33
34
  end
34
35
 
@@ -123,6 +124,10 @@ describe Smaak::Server do
123
124
  expect(@auth_message.identifier).to eql(@test_identifier)
124
125
  end
125
126
 
127
+ it "should set the route-info to the x-smaak-route-info header value" do
128
+ expect(@auth_message.route_info).to eql(@test_route_info)
129
+ end
130
+
126
131
  it "should set the nonce to the x-smaak-nonce header value" do
127
132
  expect(@auth_message.nonce).to eql(@test_nonce)
128
133
  end
@@ -11,9 +11,10 @@ describe Smaak do
11
11
  @test_expires = Time.now.to_i + 5
12
12
  @test_psk = "testpresharedkey"
13
13
  @test_identifier = 'test-service-1.cpt1.host-h.net'
14
+ @test_route_info = 'identifier'
14
15
  @test_recipient = @test_server_public_key.export
15
16
  @test_encrypt = true
16
- @auth_message = Smaak::AuthMessage.new(@test_identifier, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
17
+ @auth_message = Smaak::AuthMessage.new(@test_identifier, @test_route_info, @test_nonce, @test_expires, Smaak::Crypto::obfuscate_psk(@test_psk), @test_recipient, @test_encrypt)
17
18
  @adaptor = Smaak::create_adaptor(@request)
18
19
  @mock_specification = Smaak::Cavage04.new(@adaptor)
19
20
  end
data/spec/spec_helper.rb CHANGED
@@ -35,6 +35,7 @@ RSpec.configure do |config|
35
35
  # --seed 1234
36
36
  config.order = 'random'
37
37
  end
38
+ RSpec::Expectations.configuration.warn_about_potential_false_positives = false
38
39
 
39
40
  SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
40
41
  SimpleCov.start do
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.17
4
+ version: 0.2.0
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: 2016-05-05 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: persistent-cache-ram