authmac 1.0.3 → 1.0.4

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: e150851873e527bbdb621d19701b3d4ff7f976c7
4
- data.tar.gz: 02bc0a0836b9931e91e3e32d2d532c6bdc5be40b
3
+ metadata.gz: 90105d4d9efdd25c6c15260a90dce6a807b82413
4
+ data.tar.gz: 713c8d6560a0f879af99e5ed4d3ba1152fe2dcba
5
5
  SHA512:
6
- metadata.gz: 8a68eadb5dc40141d7a165376f577ecec25967ad321d42124b53cd3f8db333f89a3b12b407921cedf60ead0eb001156a87f3ee82eb89186560e07e17d880cdba
7
- data.tar.gz: ce5c1ef3d649f8adb7d371c86cb8a9931d84b25927eb5ee349d33ccb7241a68bdf81cf6a4aaee7661a5c17dbaaf121f8238c9362cfa72c5a05ba084f2e75ef39
6
+ metadata.gz: bac599e7b2238e0b346b8bb3b5dbc4bf2e7243c464a0b4fab90325264f10a4edf4e49ff39162d1c5b28bebafd9b475293936d79cebe5cbda02d22a58dfa2ac12
7
+ data.tar.gz: 86f1fa8713e62e8d5ac15cb395bde67d750daddbd339c1b544e5527ce259799ba0d2a53e1b36f618bfbdb4a60d56891113fab3201f34a4334e44395453f856ff
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## Version 1.0.3 / 2014-5-12
1
+ ## Version 1.0.4 / 2014-06-20
2
+
3
+ * Added HmacChecker#with_signature which returns the given hash with the HMAC merged in.
4
+
5
+ ## Version 1.0.3 / 2014-05-12
2
6
 
3
7
  * Raise error when insecure key is being used, assuming all keys are hex values (see rfc2104)
4
- * Only compatible with ruby 2
8
+ * Only compatible with ruby 2
@@ -17,6 +17,10 @@ module Authmac
17
17
  OpenSSL::HMAC.hexdigest(digester, @secret, message_string(hash))
18
18
  end
19
19
 
20
+ def with_signature(hash, hmac_key = :hmac)
21
+ hash.merge({hmac_key => sign(hash)})
22
+ end
23
+
20
24
  private
21
25
 
22
26
  def digester
@@ -1,3 +1,3 @@
1
1
  module Authmac
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -47,6 +47,18 @@ module Authmac
47
47
  end
48
48
  end
49
49
 
50
+ describe '#with_signature' do
51
+ it 'adds the hmac' do
52
+ hash = {second: 'another', first: 'parameter'}
53
+ expect(checker.with_signature(hash)).to eq(hash.merge(hmac: hmacify('parameter|another')))
54
+ end
55
+
56
+ it 'allows overriding the key to place the hmac under' do
57
+ hash = {second: 'another', first: 'parameter'}
58
+ expect(checker.with_signature(hash, :sig)).to eq(hash.merge(sig: hmacify('parameter|another')))
59
+ end
60
+ end
61
+
50
62
  describe '#calculate_hmac' do
51
63
  it 'generates hmac' do
52
64
  expect(checker.sign(second: 'another', first: 'parameter')).to eq(hmacify('parameter|another'))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.1
90
+ rubygems_version: 2.2.2
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Single Sign-On implementation based on HMAC.
@@ -95,3 +95,4 @@ test_files:
95
95
  - spec/authmac/hmac_checker_spec.rb
96
96
  - spec/authmac/timestamp_checker_spec.rb
97
97
  - spec/authmac_spec.rb
98
+ has_rdoc: