symmetric-encryption 4.4.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17ec7e95cd640a1bc8b960bff9244557e3dcd58bb58744b054e4bb7ef95a051a
4
- data.tar.gz: 36230ce36bf337f98d5cf70e45c5ed1658faeed8ce650cd9b4b7d12354a477df
3
+ metadata.gz: 8e2c2ad605877325606a7a1d186768164ea937ea31c00dfbd03e9d9cb2af9fc4
4
+ data.tar.gz: c09040519caf78c1e323f176bbb9a4b1927285d9d8fda9db22cbf98e79c65445
5
5
  SHA512:
6
- metadata.gz: 4d880e284b3aa211e2a4bdeb872ff294d8c8743eb033edcafd6ec7ee569da3390b12821e555b1efe98503b2e4c4c05d0380f5da6d09577dfcd57badc12c0bce2
7
- data.tar.gz: 36453ff31c896a7b7359b66cd53d3777f71b6855d53d8f002a77d7af91e3fe21c1a346869c0414aecbe8cc92c7e93dd73701edaa751072df6dcdd9459dd74752
6
+ metadata.gz: d21beddef347085e73ac34ef570500d5b670b4d8d46db0bcc6bdf1578d677224e29c13810b425dc0889aee9c6af8e180b29d53f9a13a4d4702303b6bc099a88c
7
+ data.tar.gz: b8dd362780461aaa8b207ca1ba7c337ecbf05dd8b56a7c49cef1df2a04cff92fa76afe1efa1d16db8efb0d695cf9462aed2ad2ecf6c07703e5687a91c37b6188
data/README.md CHANGED
@@ -27,6 +27,13 @@ Checkout the sister project [Rocket Job](http://rocketjob.io): Ruby's missing ba
27
27
 
28
28
  Fully supports Symmetric Encryption to encrypt data in flight and at rest while running jobs in the background.
29
29
 
30
+ ## Upgrading to Rails V7
31
+
32
+ There is a method naming conflict with Rails 7, which has its own `encrypted_attributes` method.
33
+
34
+ As a result the older `attr_encrypted` mechanism is no longer available with Rails 7.
35
+ Migrate the use of `attr_encrypted` to `attribute` as described in the [Frameworks Guide](https://encryption.rocketjob.io/frameworks.html).
36
+
30
37
  ## Upgrading to SymmetricEncryption V4
31
38
 
32
39
  Version 4 of Symmetric Encryption has completely adopted the Ruby keyword arguments on most API's where
@@ -24,6 +24,10 @@ module SymmetricEncryption
24
24
  )
25
25
  end
26
26
 
27
+ def changed_in_place?(raw_old_value, new_value)
28
+ deserialize(raw_old_value) != new_value
29
+ end
30
+
27
31
  private
28
32
 
29
33
  # Symmetric Encryption uses coercible gem to handle casting
@@ -27,7 +27,7 @@ module SymmetricEncryption
27
27
 
28
28
  # Reads the entire configuration for all environments from the supplied file name.
29
29
  def self.read_file(file_name)
30
- config = YAML.load(ERB.new(File.new(file_name).read).result)
30
+ config = load_yaml(ERB.new(File.new(file_name).read).result)
31
31
  config = deep_symbolize_keys(config)
32
32
  config.each_pair { |_env, cfg| SymmetricEncryption::Config.send(:migrate_old_formats!, cfg) }
33
33
  config
@@ -75,7 +75,7 @@ module SymmetricEncryption
75
75
  begin
76
76
  raise(ConfigError, "Cannot find config file: #{file_name}") unless File.exist?(file_name)
77
77
 
78
- env_config = YAML.load(ERB.new(File.new(file_name).read).result)[env]
78
+ env_config = self.class.load_yaml(ERB.new(File.new(file_name).read).result)[env]
79
79
  raise(ConfigError, "Cannot find environment: #{env} in config file: #{file_name}") unless env_config
80
80
 
81
81
  env_config = self.class.send(:deep_symbolize_keys, env_config)
@@ -163,5 +163,11 @@ module SymmetricEncryption
163
163
  end
164
164
 
165
165
  private_class_method :migrate_old_formats!
166
+
167
+ def self.load_yaml(src)
168
+ return YAML.safe_load(src, permitted_classes: [Symbol], aliases: true) if Psych::VERSION.to_i >= 4
169
+
170
+ YAML.load(src)
171
+ end
166
172
  end
167
173
  end
@@ -220,8 +220,7 @@ module SymmetricEncryption
220
220
 
221
221
  # Migrate old encrypted_iv
222
222
  if (encrypted_iv = config.delete(:encrypted_iv)) && private_rsa_key
223
- encrypted_iv = RSAKey.new(private_rsa_key).decrypt(encrypted_iv)
224
- config[:iv] = ::Base64.decode64(encrypted_iv)
223
+ config[:iv] = RSAKey.new(private_rsa_key).decrypt(::Base64.decode64(encrypted_iv))
225
224
  end
226
225
 
227
226
  # Migrate old iv_filename
@@ -1,3 +1,3 @@
1
1
  module SymmetricEncryption
2
- VERSION = "4.4.0".freeze
2
+ VERSION = "4.6.0".freeze
3
3
  end
@@ -17,7 +17,10 @@ begin
17
17
  ActiveRecord::Type.register(:encrypted, SymmetricEncryption::ActiveRecord::EncryptedAttribute)
18
18
  end
19
19
 
20
- ActiveRecord::Base.include(SymmetricEncryption::ActiveRecord::AttrEncrypted)
20
+ # Remove old way of defining attributes with Rails 7 since it conflicts with the method names.
21
+ if ActiveRecord.version <= Gem::Version.new("7.0.0")
22
+ ActiveRecord::Base.include(SymmetricEncryption::ActiveRecord::AttrEncrypted)
23
+ end
21
24
  end
22
25
 
23
26
  ActiveSupport.on_load(:mongoid) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symmetric-encryption
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-07 00:00:00.000000000 Z
11
+ date: 2022-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coercible
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.2.22
89
+ rubygems_version: 3.3.7
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Encrypt ActiveRecord and Mongoid attributes, files and passwords in configuration