action_encrypt 0.1.1 → 0.2.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: 77578faa5509a3f8ca0489331a6e6d8de6a716c9841457167b82c75c4e7f88de
4
- data.tar.gz: 347b93c2f523a066a5126a4d327008b2ec8e6f18b6876c8d29eec61470cb1dd0
3
+ metadata.gz: 850dbcfb530af9a8e6b85b1885c9ea4390c3850dae49aaaebc67ea383c7dcaf4
4
+ data.tar.gz: 56bb5d876520484d803e21d5bb0e56be1fa168de379e2d0530c8e6a70c8f142e
5
5
  SHA512:
6
- metadata.gz: aa25aa15c59e48d1d663000cc49d67e55fd9d2aab3d96756ee22831d2a68f50ad41da635a7ee2282a95442c9fe01031c6f0eb078583bb06c2160277f12f86fc1
7
- data.tar.gz: 8dbea43c52706497c144c3556b3a8ae781338e87336ab385b0968cdfcc0657b18c1945861c5de8bf43c1649bae17198f2847c99e14f7fba22a9556a72e4b0798
6
+ metadata.gz: 961ae2946e16d396104cb911f2420bb449d204cb617d91ee10fc6732846c1057055f6ed8c100b3b6d87160135e7989ebc52f22a8cdd730e113ab5ab308e13d66
7
+ data.tar.gz: 34659ca935c25192bbfe2c313acf06d057a5b44098cb66e3924c146dd7a16f921c9d68f613eb282b40efb7a8371dad01bcd860b308e4229bb0204b09e69751bb
data/README.md CHANGED
@@ -18,10 +18,14 @@ Install migrations:
18
18
  $ rails action_encrypt:install:migrations
19
19
  ```
20
20
 
21
- Add a key_encryption_key to your Rails encrypted credentials file. Generate
22
- one using `SecureRandom.hex(32)`
23
- ```yml
24
- key_encryption_key: <<key>>
21
+ Create `action_encrypt.rb` in your initializers folder and set encryption keys. Generate them
22
+ using `SecureRandom.hex(32)`. You can decide between storing the values in ENV or using rails encrypted credentials system.
23
+
24
+ ```ruby
25
+ ActionEncrypt.configure do |config|
26
+ config.key_encryption_key = ENV.fetch('KEY_ENCRYPTION_KEY')
27
+ config.blind_index_key = ENV.fetch('BLIND_INDEX_KEY')
28
+ end
25
29
  ```
26
30
 
27
31
  Create a Data Encryption Key
@@ -10,7 +10,7 @@ module ActionEncrypt
10
10
  end
11
11
 
12
12
  def encryption_key
13
- [Rails.application.credentials.key_encryption_key].pack("H*")
13
+ [ActionEncrypt.configuration.key_encryption_key].pack("H*")
14
14
  end
15
15
 
16
16
  def promote!
@@ -0,0 +1,6 @@
1
+ class UniqueIndexIvColumns < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_index :action_encrypt_data_encryption_keys, :encrypted_key_iv, unique: true
4
+ add_index :action_encrypt_encrypted_fields, :encrypted_blob_iv, unique: true
5
+ end
6
+ end
@@ -6,7 +6,9 @@ module ActionEncrypt
6
6
 
7
7
  class_methods do
8
8
  def search_encrypted(name, opts = {})
9
- blind_index :"#{name}", key: [Rails.application.credentials.blind_index_key].pack("H*")
9
+ require 'blind_index'
10
+
11
+ blind_index :"#{name}", key: [ActionEncrypt.configuration.blind_index_key].pack("H*")
10
12
 
11
13
  before_validation :"compute_#{name}_bidx"
12
14
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionEncrypt
4
+ class Configuration
5
+ attr_accessor :key_encryption_key, :blind_index_key
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module ActionEncrypt
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -6,4 +6,15 @@ module ActionEncrypt
6
6
  extend ActiveSupport::Autoload
7
7
 
8
8
  autoload :Attribute
9
+ autoload :Configuration
10
+
11
+ class << self
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+ end
9
20
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_encrypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Van Der Beek
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description:
69
+ description:
70
70
  email:
71
71
  - earlynovrock@gmail.com
72
72
  executables: []
@@ -83,8 +83,10 @@ files:
83
83
  - db/migrate/20190404115831_create_action_encrypt_encrypted_fields.rb
84
84
  - db/migrate/20190404121918_create_action_encrypt_data_encryption_keys.rb
85
85
  - db/migrate/20190404122056_add_data_encryption_key_to_action_encrypt_encrypted_fields.rb
86
+ - db/migrate/20190628112807_unique_index_iv_columns.rb
86
87
  - lib/action_encrypt.rb
87
88
  - lib/action_encrypt/attribute.rb
89
+ - lib/action_encrypt/configuration.rb
88
90
  - lib/action_encrypt/engine.rb
89
91
  - lib/action_encrypt/version.rb
90
92
  - lib/tasks/action_encrypt_tasks.rake
@@ -92,7 +94,7 @@ homepage: https://github.com/dvanderbeek/action_encrypt
92
94
  licenses:
93
95
  - MIT
94
96
  metadata: {}
95
- post_install_message:
97
+ post_install_message:
96
98
  rdoc_options: []
97
99
  require_paths:
98
100
  - lib
@@ -107,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
109
  - !ruby/object:Gem::Version
108
110
  version: '0'
109
111
  requirements: []
110
- rubygems_version: 3.0.1
111
- signing_key:
112
+ rubygems_version: 3.0.6
113
+ signing_key:
112
114
  specification_version: 4
113
115
  summary: Easily add encrypted fields to your models.
114
116
  test_files: []