lockbox 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +33 -0
- data/lib/lockbox.rb +7 -0
- data/lib/lockbox/model.rb +16 -2
- data/lib/lockbox/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: fe55b94af6abc4b2cf562badea225c8aff715ae3be8cc40e81f645ae6c0a6a9b
|
4
|
+
data.tar.gz: dd6c5dbd4d3280548212ca145f56b99909b5d4af07784bc095fc1df6afd156ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a50542c82cfbb3cab24e6e18f2aaec1862b0a76dfef762b416710a67b17ec9171be6620b48bd59c50ef8d02f29bd195e860579e96fcbb8f2667cd151d277a56
|
7
|
+
data.tar.gz: 42ce91cccba7bbed944a6454e076f7f8db08d107aa96da5e9a69e862faa0c465e27e4441007b9964e0ce953ce5294bbd3120d55e6b91aea516a2597ab9375e9d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,7 @@ Then follow the instructions below for the data you want to encrypt.
|
|
47
47
|
#### Database Fields
|
48
48
|
|
49
49
|
- [Active Record](#active-record)
|
50
|
+
- [Action Text](#action-text)
|
50
51
|
- [Mongoid](#mongoid)
|
51
52
|
|
52
53
|
#### Files
|
@@ -185,6 +186,38 @@ class User < ApplicationRecord
|
|
185
186
|
end
|
186
187
|
```
|
187
188
|
|
189
|
+
## Action Text
|
190
|
+
|
191
|
+
Create a migration with:
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
class AddBodyCiphertextToRichTexts < ActiveRecord::Migration[6.0]
|
195
|
+
def change
|
196
|
+
add_column :action_text_rich_texts, :body_ciphertext, :text
|
197
|
+
end
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
Create `config/initializers/lockbox.rb` with:
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
Lockbox.encrypts_action_text_body(migrating: true)
|
205
|
+
```
|
206
|
+
|
207
|
+
Migrate existing data:
|
208
|
+
|
209
|
+
```ruby
|
210
|
+
Lockbox.migrate(ActionText::RichText)
|
211
|
+
```
|
212
|
+
|
213
|
+
Update the initializer:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
Lockbox.encrypts_action_text_body
|
217
|
+
```
|
218
|
+
|
219
|
+
And drop the unencrypted column.
|
220
|
+
|
188
221
|
## Mongoid
|
189
222
|
|
190
223
|
Add to your model:
|
data/lib/lockbox.rb
CHANGED
@@ -93,4 +93,11 @@ module Lockbox
|
|
93
93
|
def self.new(**options)
|
94
94
|
Encryptor.new(**options)
|
95
95
|
end
|
96
|
+
|
97
|
+
def self.encrypts_action_text_body(**options)
|
98
|
+
# runs every reload
|
99
|
+
ActiveSupport.on_load(:action_text_rich_text) do
|
100
|
+
ActionText::RichText.encrypts :body, **options
|
101
|
+
end
|
102
|
+
end
|
96
103
|
end
|
data/lib/lockbox/model.rb
CHANGED
@@ -223,6 +223,20 @@ module Lockbox
|
|
223
223
|
|
224
224
|
send("lockbox_direct_#{name}=", message)
|
225
225
|
|
226
|
+
# warn every time, as this should be addressed
|
227
|
+
# maybe throw an error in the future
|
228
|
+
if !options[:migrating]
|
229
|
+
if activerecord
|
230
|
+
if self.class.columns_hash.key?(name.to_s)
|
231
|
+
warn "[lockbox] WARNING: Unencrypted column with same name: #{name}. Set `ignored_columns` or remove it to protect the data."
|
232
|
+
end
|
233
|
+
else
|
234
|
+
if self.class.fields.key?(name.to_s)
|
235
|
+
warn "[lockbox] WARNING: Unencrypted field with same name: #{name}. Remove it to protect the data."
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
226
240
|
super(message)
|
227
241
|
end
|
228
242
|
|
@@ -270,7 +284,7 @@ module Lockbox
|
|
270
284
|
table = activerecord ? table_name : collection_name.to_s
|
271
285
|
|
272
286
|
unless message.nil?
|
273
|
-
# TODO use attribute type class in 0.
|
287
|
+
# TODO use attribute type class in 0.5.0
|
274
288
|
case options[:type]
|
275
289
|
when :boolean
|
276
290
|
message = ActiveRecord::Type::Boolean.new.serialize(message)
|
@@ -324,7 +338,7 @@ module Lockbox
|
|
324
338
|
end
|
325
339
|
|
326
340
|
unless message.nil?
|
327
|
-
# TODO use attribute type class in 0.
|
341
|
+
# TODO use attribute type class in 0.5.0
|
328
342
|
case options[:type]
|
329
343
|
when :boolean
|
330
344
|
message = message == "t"
|
data/lib/lockbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|