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 +4 -4
- data/README.md +4 -0
- data/lib/kms_rails/active_record.rb +4 -1
- data/lib/kms_rails/version.rb +1 -1
- 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: f2118b63c674364c221226b10ae0e100f8ab8802
|
4
|
+
data.tar.gz: e0d597bdbd866795280db1e22d538c777031e4c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/kms_rails/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|