lockbox 0.6.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +8 -1
- data/lib/lockbox.rb +5 -0
- data/lib/lockbox/carrier_wave_extensions.rb +11 -3
- data/lib/lockbox/model.rb +12 -0
- data/lib/lockbox/railtie.rb +4 -0
- 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: 723ecf0e8367d053e2e80afddfa954559901f1b8c44d3a7cdb3ad562b3f5135a
|
4
|
+
data.tar.gz: 6c512616214fa1fdca743539769e1d2bd5f91135337a904b89ba58273dc9dbc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 440177ac7cbe84f4e20eeedffe3045060debab17f178631bcba0b631e2e4c656bce1c0977f3af9dc84ce06788cf370626fed9053d3a4503632bc3daa0b6ab43d
|
7
|
+
data.tar.gz: ab23683aa75ff078b88cdfb65f29564691f5785b49549fa1d9286baf11a9959f7d49f0a21a7c84d10dd7d181c8affd05ca739769cdbe68193e4fb211f9a932af
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -35,10 +35,17 @@ Set the following environment variable with your key (you can use this one in de
|
|
35
35
|
LOCKBOX_MASTER_KEY=0000000000000000000000000000000000000000000000000000000000000000
|
36
36
|
```
|
37
37
|
|
38
|
+
or add it to your credentials for each environment (`rails credentials:edit --environment <env>` for Rails 6+)
|
39
|
+
|
40
|
+
```yml
|
41
|
+
lockbox:
|
42
|
+
master_key: "0000000000000000000000000000000000000000000000000000000000000000"
|
43
|
+
```
|
44
|
+
|
38
45
|
or create `config/initializers/lockbox.rb` with something like
|
39
46
|
|
40
47
|
```ruby
|
41
|
-
Lockbox.master_key = Rails.application.credentials.
|
48
|
+
Lockbox.master_key = Rails.application.credentials.lockbox[:master_key]
|
42
49
|
```
|
43
50
|
|
44
51
|
Then follow the instructions below for the data you want to encrypt.
|
data/lib/lockbox.rb
CHANGED
@@ -27,6 +27,11 @@ end
|
|
27
27
|
|
28
28
|
if defined?(ActiveSupport.on_load)
|
29
29
|
ActiveSupport.on_load(:active_record) do
|
30
|
+
# TODO raise error in 0.7.0
|
31
|
+
if ActiveRecord::VERSION::STRING.to_f <= 5.0
|
32
|
+
warn "Active Record version (#{ActiveRecord::VERSION::STRING}) not supported in this version of Lockbox (#{Lockbox::VERSION})"
|
33
|
+
end
|
34
|
+
|
30
35
|
extend Lockbox::Model
|
31
36
|
extend Lockbox::Model::Attached
|
32
37
|
ActiveRecord::Calculations.prepend Lockbox::Calculations
|
@@ -32,9 +32,14 @@ module Lockbox
|
|
32
32
|
read.bytesize
|
33
33
|
end
|
34
34
|
|
35
|
-
# based on CarrierWave::SanitizedFile#mime_magic_content_type
|
36
35
|
def content_type
|
37
|
-
|
36
|
+
if CarrierWave::VERSION.to_i >= 2
|
37
|
+
# based on CarrierWave::SanitizedFile#mime_magic_content_type
|
38
|
+
MimeMagic.by_magic(read).try(:type) || "invalid/invalid"
|
39
|
+
else
|
40
|
+
# uses filename
|
41
|
+
super
|
42
|
+
end
|
38
43
|
end
|
39
44
|
|
40
45
|
# disable processing since already processed
|
@@ -98,7 +103,10 @@ module Lockbox
|
|
98
103
|
end
|
99
104
|
|
100
105
|
if CarrierWave::VERSION.to_i > 2
|
101
|
-
raise "CarrierWave version not supported in this version of Lockbox
|
106
|
+
raise "CarrierWave version (#{CarrierWave::VERSION}) not supported in this version of Lockbox (#{Lockbox::VERSION})"
|
107
|
+
elsif CarrierWave::VERSION.to_i < 1
|
108
|
+
# TODO raise error in 0.7.0
|
109
|
+
warn "CarrierWave version (#{CarrierWave::VERSION}) not supported in this version of Lockbox (#{Lockbox::VERSION})"
|
102
110
|
end
|
103
111
|
|
104
112
|
CarrierWave::Uploader::Base.extend(Lockbox::CarrierWaveExtensions)
|
data/lib/lockbox/model.rb
CHANGED
@@ -247,6 +247,18 @@ module Lockbox
|
|
247
247
|
else
|
248
248
|
attribute name, :string
|
249
249
|
end
|
250
|
+
else
|
251
|
+
# hack for Active Record 6.1
|
252
|
+
# to set string type after serialize
|
253
|
+
# otherwise, type gets set to ActiveModel::Type::Value
|
254
|
+
# which always returns false for changed_in_place?
|
255
|
+
# earlier versions of Active Record take the previous code path
|
256
|
+
if ActiveRecord::VERSION::STRING.to_f >= 6.1 && attributes_to_define_after_schema_loads[name.to_s].first.is_a?(Proc)
|
257
|
+
attribute_type = attributes_to_define_after_schema_loads[name.to_s].first.call
|
258
|
+
if attribute_type.is_a?(ActiveRecord::Type::Serialized) && attribute_type.subtype.nil?
|
259
|
+
attribute name, ActiveRecord::Type::Serialized.new(ActiveRecord::Type::String.new, attribute_type.coder)
|
260
|
+
end
|
261
|
+
end
|
250
262
|
end
|
251
263
|
|
252
264
|
define_method("#{name}_was") do
|
data/lib/lockbox/railtie.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Lockbox
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "lockbox" do |app|
|
4
|
+
if defined?(Rails.application.credentials)
|
5
|
+
Lockbox.master_key ||= Rails.application.credentials.dig(:lockbox, :master_key)
|
6
|
+
end
|
7
|
+
|
4
8
|
require "lockbox/carrier_wave_extensions" if defined?(CarrierWave)
|
5
9
|
|
6
10
|
if defined?(ActiveStorage)
|
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.6.
|
4
|
+
version: 0.6.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-12-
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|