kms_rails 0.0.5 → 0.0.6

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: 59b22bd75675cc0973d37c1d05cc270ad708e856
4
- data.tar.gz: f1d5963c493dde234bfe4da707c169f40bd3960b
3
+ metadata.gz: f2118b63c674364c221226b10ae0e100f8ab8802
4
+ data.tar.gz: e0d597bdbd866795280db1e22d538c777031e4c2
5
5
  SHA512:
6
- metadata.gz: c44f8efcaf9d0a5bff949cbd7ae94521a2d2e962008c27c3e491cda9273a7653a9e8489d4c3c6d19cf28729a196c2a540a4e7e93f9816572a1a6efa029afd1c9
7
- data.tar.gz: edb200a86655ac83d9d05f1c485d5cdef3c58250e9092a231d18098a127a6a8a06369751b41c2f25f76cc2705c7f6c80741a8e5ddad936f5a55c1aeb67c4cc96
6
+ metadata.gz: 4b123ed8023a46f1bc524494fe2c08b913c00f8b1f49e22449663cd4a679964568db75f82031f6cdaa3758ba4385bb565f970b45d9b5f05179f4d8969d09b20c
7
+ data.tar.gz: 65e73fa8898b985086ab192ce939dd3d5cbeded70a5051be29f60b39907a730c55de7cf4bc2b230023982bfd69133858b36c120717270cb7808064321204f474
data/README.md CHANGED
@@ -51,6 +51,10 @@ To clear a retained decrypted value, call:
51
51
 
52
52
  This will attempt mutate the stored string to contain just null bytes, and then dereference it to be garbage collected. No guarantees are provided about additional copies of the retained data being cached elsewhere.
53
53
 
54
+ ### Data Serialization
55
+
56
+ By default kms_rails will convert your encrypted values into strings, however if you would like higher level structures to be stored, you can set `msgpack: true` on any kms_attr declaration. This will encode and decode your values using [MessagePack](https://github.com/msgpack/msgpack-ruby), as long as those value types are supported by it.
57
+
54
58
  ## ActiveJob
55
59
 
56
60
  To use on ActiveJob, simply put the following code in your job for the arguments you wish to encrypt in flight.
@@ -10,7 +10,7 @@ module KmsRails
10
10
  end
11
11
 
12
12
  module ClassMethods
13
- def kms_attr(field, key_id:, retain: false, context_key: nil, context_value: nil)
13
+ def kms_attr(field, key_id:, retain: false, msgpack: false, context_key: nil, context_value: nil)
14
14
  include InstanceMethods
15
15
 
16
16
  real_field = "#{field}_enc"
@@ -26,6 +26,7 @@ module KmsRails
26
26
  return
27
27
  end
28
28
 
29
+ data = data.to_msgpack if msgpack
29
30
  encrypted_data = enc.encrypt(data)
30
31
 
31
32
  set_retained(field, data) if retain
@@ -43,9 +44,11 @@ module KmsRails
43
44
  return nil unless hash
44
45
 
45
46
  if retain && (plaintext = get_retained(field))
47
+ plaintext = MessagePack.unpack(plaintext) if msgpack
46
48
  plaintext
47
49
  else
48
50
  plaintext = enc.decrypt(hash)
51
+ plaintext = MessagePack.unpack(plaintext) if msgpack
49
52
  set_retained(field, plaintext) if retain
50
53
  plaintext
51
54
  end
@@ -1,3 +1,3 @@
1
1
  module KmsRails
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kms_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Tyndall
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-05 00:00:00.000000000 Z
12
+ date: 2016-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord