lockbox 1.3.0 → 1.3.2
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 +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +7 -7
- data/lib/lockbox/model.rb +23 -6
- data/lib/lockbox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 395cfb4c691d2ddb7280f6b0fe7e0e0bcc663c128a391751d6e2d03087c7c0f8
|
4
|
+
data.tar.gz: 964271ba8bc79f94c940daf2f90c88da800a03560dde7870d9e69da67eff9e5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6833415a739d81b5570537616e8181a69d3b333d1f3ce3538e7a6f3f6c4a937611d07769d529f43c601bbf000c99cd55c89375b7a3be5915cb884df1785395ba
|
7
|
+
data.tar.gz: eb64b479c6564db53d8b02821c987dc391c4c424e52de708f1a7b48308bd6ad381a8a72cd25f85cdbbd32b941f0e634efaa759269db764b9fba9efd3a0e0eea0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.3.2 (2024-01-10)
|
2
|
+
|
3
|
+
- Fixed issue with serialized attributes
|
4
|
+
|
5
|
+
## 1.3.1 (2024-01-06)
|
6
|
+
|
7
|
+
- Fixed error with `array` and `hash` types and no default column serializer with Rails 7.1
|
8
|
+
- Fixed Action Text deserialization with Rails 7.1
|
9
|
+
|
1
10
|
## 1.3.0 (2023-07-02)
|
2
11
|
|
3
12
|
- Added support for CarrierWave 3
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
Learn [the principles behind it](https://ankane.org/modern-encryption-rails), [how to secure emails with Devise](https://ankane.org/securing-user-emails-lockbox), and [how to secure sensitive data in Rails](https://ankane.org/sensitive-data-rails).
|
11
11
|
|
12
|
-
[](https://github.com/ankane/lockbox/actions)
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -72,7 +72,7 @@ Then follow the instructions below for the data you want to encrypt.
|
|
72
72
|
Create a migration with:
|
73
73
|
|
74
74
|
```ruby
|
75
|
-
class AddEmailCiphertextToUsers < ActiveRecord::Migration[7.
|
75
|
+
class AddEmailCiphertextToUsers < ActiveRecord::Migration[7.1]
|
76
76
|
def change
|
77
77
|
add_column :users, :email_ciphertext, :text
|
78
78
|
end
|
@@ -249,7 +249,7 @@ User.decrypt_email_ciphertext(user.email_ciphertext)
|
|
249
249
|
Create a migration with:
|
250
250
|
|
251
251
|
```ruby
|
252
|
-
class AddBodyCiphertextToRichTexts < ActiveRecord::Migration[7.
|
252
|
+
class AddBodyCiphertextToRichTexts < ActiveRecord::Migration[7.1]
|
253
253
|
def change
|
254
254
|
add_column :action_text_rich_texts, :body_ciphertext, :text
|
255
255
|
end
|
@@ -380,7 +380,7 @@ Encryption is applied to all versions after processing.
|
|
380
380
|
You can mount the uploader [as normal](https://github.com/carrierwaveuploader/carrierwave#activerecord). With Active Record, this involves creating a migration:
|
381
381
|
|
382
382
|
```ruby
|
383
|
-
class AddLicenseToUsers < ActiveRecord::Migration[7.
|
383
|
+
class AddLicenseToUsers < ActiveRecord::Migration[7.1]
|
384
384
|
def change
|
385
385
|
add_column :users, :license, :string
|
386
386
|
end
|
@@ -908,7 +908,7 @@ end
|
|
908
908
|
You can use `binary` columns for the ciphertext instead of `text` columns.
|
909
909
|
|
910
910
|
```ruby
|
911
|
-
class AddEmailCiphertextToUsers < ActiveRecord::Migration[7.
|
911
|
+
class AddEmailCiphertextToUsers < ActiveRecord::Migration[7.1]
|
912
912
|
def change
|
913
913
|
add_column :users, :email_ciphertext, :binary
|
914
914
|
end
|
@@ -959,7 +959,7 @@ end
|
|
959
959
|
Create a migration with:
|
960
960
|
|
961
961
|
```ruby
|
962
|
-
class MigrateToLockbox < ActiveRecord::Migration[7.
|
962
|
+
class MigrateToLockbox < ActiveRecord::Migration[7.1]
|
963
963
|
def change
|
964
964
|
add_column :users, :name_ciphertext, :text
|
965
965
|
add_column :users, :email_ciphertext, :text
|
@@ -992,7 +992,7 @@ end
|
|
992
992
|
Then remove the previous gem from your Gemfile and drop its columns.
|
993
993
|
|
994
994
|
```ruby
|
995
|
-
class RemovePreviousEncryptedColumns < ActiveRecord::Migration[7.
|
995
|
+
class RemovePreviousEncryptedColumns < ActiveRecord::Migration[7.1]
|
996
996
|
def change
|
997
997
|
remove_column :users, :encrypted_name, :text
|
998
998
|
remove_column :users, :encrypted_name_iv, :text
|
data/lib/lockbox/model.rb
CHANGED
@@ -324,13 +324,23 @@ module Lockbox
|
|
324
324
|
attribute name, attribute_type
|
325
325
|
|
326
326
|
if ActiveRecord::VERSION::STRING.to_f >= 7.1
|
327
|
-
|
328
|
-
|
329
|
-
|
327
|
+
case options[:type]
|
328
|
+
when :json
|
329
|
+
serialize name, coder: JSON
|
330
|
+
when :hash
|
331
|
+
serialize name, type: Hash, coder: default_column_serializer || YAML
|
332
|
+
when :array
|
333
|
+
serialize name, type: Array, coder: default_column_serializer || YAML
|
334
|
+
end
|
330
335
|
else
|
331
|
-
|
332
|
-
|
333
|
-
|
336
|
+
case options[:type]
|
337
|
+
when :json
|
338
|
+
serialize name, JSON
|
339
|
+
when :hash
|
340
|
+
serialize name, Hash
|
341
|
+
when :array
|
342
|
+
serialize name, Array
|
343
|
+
end
|
334
344
|
end
|
335
345
|
elsif !attributes_to_define_after_schema_loads.key?(name.to_s)
|
336
346
|
# when migrating it's best to specify the type directly
|
@@ -499,6 +509,9 @@ module Lockbox
|
|
499
509
|
clear_attribute_change(name)
|
500
510
|
end
|
501
511
|
end
|
512
|
+
|
513
|
+
# ensure same object is returned as next call
|
514
|
+
message = super()
|
502
515
|
else
|
503
516
|
instance_variable_set("@#{name}", message)
|
504
517
|
end
|
@@ -615,6 +628,10 @@ module Lockbox
|
|
615
628
|
else
|
616
629
|
# use original name for serialized attributes if no type specified
|
617
630
|
type = (try(:attribute_types) || {})[(options[:type] ? name : original_name).to_s]
|
631
|
+
# for Action Text
|
632
|
+
if activerecord && type.is_a?(ActiveRecord::Type::Serialized) && defined?(ActionText::Content) && type.coder == ActionText::Content
|
633
|
+
message.force_encoding(Encoding::UTF_8)
|
634
|
+
end
|
618
635
|
message = type.deserialize(message) if type
|
619
636
|
message.force_encoding(Encoding::UTF_8) if !type || type.is_a?(ActiveModel::Type::String)
|
620
637
|
end
|
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: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.5.3
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Modern encryption for Ruby and Rails
|