active_record_encryption 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/active_record_encryption/encrypted_attribute.rb +1 -1
- data/lib/active_record_encryption/encryptor/base.rb +1 -1
- data/lib/active_record_encryption/encryptor/registry.rb +6 -23
- data/lib/active_record_encryption/serializer_with_cast.rb +11 -7
- data/lib/active_record_encryption/type.rb +1 -1
- data/lib/active_record_encryption/version.rb +1 -1
- metadata +10 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc2770632c4ba57ce5f3b807e9fe4e45ef18e959176ae907635e65a0de4f686d
|
4
|
+
data.tar.gz: 7f98301e66f31aaa043cd5c3a2ab58e655d7da9023bd8fd1d6a310b938b642e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5884f04a7b4e6fab65ce2044502b5387c172917442c4d29715bd368c75cdecd9b49bb6862c8493bd7668bd3780c431d036fbd8dfac5a2cd9d6a12e33e2453790
|
7
|
+
data.tar.gz: 6f1c82c9b173fe8d6cdb19cf6a71e6dc9ef8be793028b27a5e230b0f885554c700f105f2354b1c74d905d49384afcb44480f3f9f5254c15867e0a8200ade8c0c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,7 @@ class PointLog < ActiveRecord::Base
|
|
49
49
|
encrypted_attribute(:serialized_address, :string)
|
50
50
|
|
51
51
|
# Change encryptor
|
52
|
-
encrypted_attribute(:name, :field, encryption: { encryptor: :active_support, key: ENV['ENCRYPTION_KEY'], salt: ['ENCRYPTION_SALT'] })
|
52
|
+
encrypted_attribute(:name, :field, encryption: { encryptor: :active_support, key: ENV['ENCRYPTION_KEY'], salt: ENV['ENCRYPTION_SALT'] })
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
@@ -2,32 +2,15 @@
|
|
2
2
|
|
3
3
|
module ActiveRecordEncryption
|
4
4
|
module Encryptor
|
5
|
-
class Registry
|
6
|
-
def initialize
|
7
|
-
@registrations = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def register(encryptor_name, klass = nil, **options, &block)
|
11
|
-
block ||= proc { |_, *args| klass.new(*args) }
|
12
|
-
registrations << Registration.new(encryptor_name, block, **options)
|
13
|
-
end
|
14
|
-
|
15
|
-
def lookup(symbol, *args)
|
16
|
-
registration = find_registration(symbol, *args)
|
17
|
-
|
18
|
-
if registration
|
19
|
-
registration.call(self, symbol, *args)
|
20
|
-
else
|
21
|
-
raise ArgumentError, "Unknown encryptor #{symbol.inspect}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
5
|
+
class Registry < ActiveModel::Type::Registry
|
25
6
|
private
|
26
7
|
|
27
|
-
|
8
|
+
def registration_klass
|
9
|
+
Registration
|
10
|
+
end
|
28
11
|
|
29
|
-
def find_registration(symbol, *args)
|
30
|
-
registrations.find { |
|
12
|
+
def find_registration(symbol, *args, **kwargs)
|
13
|
+
registrations.find { |r| r.matches?(symbol, *args, **kwargs) }
|
31
14
|
end
|
32
15
|
end
|
33
16
|
|
@@ -15,15 +15,19 @@ module ActiveRecordEncryption
|
|
15
15
|
# User.attribute(:id, :boolean)
|
16
16
|
# User.where(id: 'string').to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = TRUE
|
17
17
|
# User.where(id: true).to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = TRUE
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if ActiveRecord.gem_version < Gem::Version.create('6.0')
|
19
|
+
# https://github.com/rails/rails/commit/a741208f80dd33420a56486bd9ed2b0b9862234a
|
20
|
+
refine ActiveModel::Type::Decimal do
|
21
|
+
def serialize(value)
|
22
|
+
cast(value)
|
23
|
+
end
|
21
24
|
end
|
22
|
-
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
# https://github.com/rails/rails/commit/34cc301f03aea2e579d6687a9ea9782afc1089a0
|
27
|
+
refine ActiveModel::Type::Boolean do
|
28
|
+
def serialize(value)
|
29
|
+
cast(value)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_encryption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alpaca-tc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.16'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.16'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: guard-rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,16 +84,16 @@ dependencies:
|
|
98
84
|
name: mysql2
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- - "
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0
|
96
|
+
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: pry
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,7 +194,7 @@ homepage: https://github.com/alpaca-tc/active_record_encryption
|
|
208
194
|
licenses:
|
209
195
|
- MIT
|
210
196
|
metadata: {}
|
211
|
-
post_install_message:
|
197
|
+
post_install_message:
|
212
198
|
rdoc_options: []
|
213
199
|
require_paths:
|
214
200
|
- lib
|
@@ -223,9 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
209
|
- !ruby/object:Gem::Version
|
224
210
|
version: '0'
|
225
211
|
requirements: []
|
226
|
-
|
227
|
-
|
228
|
-
signing_key:
|
212
|
+
rubygems_version: 3.1.4
|
213
|
+
signing_key:
|
229
214
|
specification_version: 4
|
230
215
|
summary: Transparent ActiveRecord encryption
|
231
216
|
test_files: []
|