action_encrypt 0.1.2 → 0.2.1

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: 05e2ef681d8e8701ac4320339013979762a43b2a94e3a003a0af59fd4c41c8df
4
- data.tar.gz: c057346d12b68003220d2a4f4fe3bcbf67f2ac90c5398d038d84b1241f4cba3c
3
+ metadata.gz: 9017388cac062e1e2f25524d728da933bad8186fd48cbc6d6c960e105200ac5e
4
+ data.tar.gz: 988f579357bfb65782555bea79b61fa74d028fd73e4ff1925cfcf70de2e8a826
5
5
  SHA512:
6
- metadata.gz: 6bcfdece534032feb299790939e300804625a501ce9aa435e21fede9719e6d5e95557373ba7eeedd39bc3f6f111309d1f62d2c5472ca34e45985a9b39439288c
7
- data.tar.gz: 5d9e36d61f60157e96cbccc213ae71e13b17a92136df6fa9ecab06e2ba87fcfe0f099af40ac439a0b41b336fc4be9d97237bf0874255e7a39c40a33fe54a9ab7
6
+ metadata.gz: d7144f8c6b7aa3dce9306c70a5f467f8862f9ce99bff4f9d90034274bade0f2b65aac797e2a2af5d6bb5724d168ca5264ec963e575dd1210ca988e7bce265f52
7
+ data.tar.gz: 53d17965935871ec19a762461e6414604319932aec885bb1fa3a2ee9e808c1bb8e9f6f11bbffb8c556ddb171247a2d3a91ace2d40fe8f4cbd651b356786f129d
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!
@@ -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,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionEncrypt
4
+ class Configuration
5
+ attr_accessor :key_encryption_key, :blind_index_key
6
+
7
+ def initialize(key_encryption_key: nil, blind_index_key: nil)
8
+ @key_encryption_key = key_encryption_key.presence || default_key_encryption_key
9
+ @blind_index_key = blind_index_key.presence || default_blind_index_key
10
+ end
11
+
12
+ private
13
+
14
+ def default_key_encryption_key
15
+ Rails.application.credentials.key_encryption_key
16
+ end
17
+
18
+ def default_blind_index_key
19
+ Rails.application.credentials.blind_index_key
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module ActionEncrypt
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.1'
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.2
4
+ version: 0.2.1
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-06-28 00:00:00.000000000 Z
11
+ date: 2021-12-23 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: []
@@ -86,6 +86,7 @@ files:
86
86
  - db/migrate/20190628112807_unique_index_iv_columns.rb
87
87
  - lib/action_encrypt.rb
88
88
  - lib/action_encrypt/attribute.rb
89
+ - lib/action_encrypt/configuration.rb
89
90
  - lib/action_encrypt/engine.rb
90
91
  - lib/action_encrypt/version.rb
91
92
  - lib/tasks/action_encrypt_tasks.rake
@@ -93,7 +94,7 @@ homepage: https://github.com/dvanderbeek/action_encrypt
93
94
  licenses:
94
95
  - MIT
95
96
  metadata: {}
96
- post_install_message:
97
+ post_install_message:
97
98
  rdoc_options: []
98
99
  require_paths:
99
100
  - lib
@@ -108,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.0.1
112
- signing_key:
112
+ rubygems_version: 3.0.6
113
+ signing_key:
113
114
  specification_version: 4
114
115
  summary: Easily add encrypted fields to your models.
115
116
  test_files: []