lockbox 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb1e70486f88d6aad134fe0a13d74e750505888415cff633138fab97887b8d0a
4
- data.tar.gz: e40ed2533aa32adc6b5c3048ab3e4588a652c0335d2eb7c408c3ea90e833f8c5
3
+ metadata.gz: fe55b94af6abc4b2cf562badea225c8aff715ae3be8cc40e81f645ae6c0a6a9b
4
+ data.tar.gz: dd6c5dbd4d3280548212ca145f56b99909b5d4af07784bc095fc1df6afd156ff
5
5
  SHA512:
6
- metadata.gz: '02051826a17857790dbf6045c4a5a3948d0843fb27a0b4799599393b8c600a43891f6c40e84c7d7dc08be2ff2fe272eaa71c2f8220b29ee6e78cb0f4e8513e53'
7
- data.tar.gz: e997bace782a9affd36a92b80de749b4aaa708caf6f8323023f0b651c8d98bfc08f6911c9946a3baa0a807d4c8020b119459523c7afd6ba66adf038c28973b96
6
+ metadata.gz: 3a50542c82cfbb3cab24e6e18f2aaec1862b0a76dfef762b416710a67b17ec9171be6620b48bd59c50ef8d02f29bd195e860579e96fcbb8f2667cd151d277a56
7
+ data.tar.gz: 42ce91cccba7bbed944a6454e076f7f8db08d107aa96da5e9a69e862faa0c465e27e4441007b9964e0ce953ce5294bbd3120d55e6b91aea516a2597ab9375e9d
@@ -1,3 +1,8 @@
1
+ ## 0.4.1 (2020-05-08)
2
+
3
+ - Added support for Action Text
4
+ - Added warning if unencrypted column exists and not migrating
5
+
1
6
  ## 0.4.0 (2020-05-03)
2
7
 
3
8
  - Load encrypted attributes when `attributes` called
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:
@@ -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
@@ -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.4.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.4.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"
@@ -1,3 +1,3 @@
1
1
  module Lockbox
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-04 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler