encryptable_attributes 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/encryptable_attributes/base.rb +14 -2
- data/lib/encryptable_attributes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c6d83bb5c347f07d499a7738d2f5d49444344528b652ee9a4fc24f430731833
|
4
|
+
data.tar.gz: 61631e757abd27db494581e09f4f863c870c87b7c7f809bfef7c7655ca88ef04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0885d409873ab3025564aac978bd62c03d6b8bb95f8525890c3da22c1f483ec77143c0baf5f5dc8089391b052565c668a5c092024a4cd799ecada3f05deb8ff7'
|
7
|
+
data.tar.gz: e3c7170468111d1b19b51734916d6e98650ef5c0e6fe2c9a5c278a293d4c8888815f0d2a40b05411f34d48a38c5d99e6d967188b14ae287314b02b20d09cc2f3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## EncryptableAttributes 0.2.2 (May 20, 2018)
|
2
|
+
* *FIX*: Don't try to encrypt and decrypt blank values (nil)
|
3
|
+
|
1
4
|
## EncryptableAttributes 0.2.1 (May 13, 2018)
|
2
5
|
* *FIX*: Rotate `ActiveSupport::MessageEncryptor` keys to ensure they are kept in case new configs are added
|
3
6
|
* Added active_record as runtime dependency
|
@@ -28,11 +28,23 @@ module EncryptableAttributes
|
|
28
28
|
def secure_attrs(*attr_names)
|
29
29
|
attr_names.each do |attr_name|
|
30
30
|
define_method :"#{attr_name}=" do |value|
|
31
|
-
|
31
|
+
if value.present?
|
32
|
+
write_attribute(attr_name, crypt.encrypt_and_sign(value))
|
33
|
+
else
|
34
|
+
# Allow to 'clear' attributes with nil
|
35
|
+
write_attribute(attr_name, value)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
define_method :"#{attr_name}" do
|
35
|
-
|
40
|
+
possibly_encrypted_value = read_attribute(attr_name)
|
41
|
+
|
42
|
+
if possibly_encrypted_value.present?
|
43
|
+
crypt.decrypt_and_verify(possibly_encrypted_value)
|
44
|
+
else
|
45
|
+
# Don't try to decrypt blank fields (nil)
|
46
|
+
possibly_encrypted_value
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
38
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: encryptable_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nils Sommer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|