encrypted_search_attributes 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/encrypted_search_attributes.gemspec +28 -0
- data/lib/encrypted_search_attributes/extensions/active_record/base.rb +36 -0
- data/lib/encrypted_search_attributes/version.rb +3 -0
- data/lib/encrypted_search_attributes.rb +3 -0
- data/spec/acceptance/attr_encrypted_search_spec.rb +75 -0
- data/spec/config/database.yml +5 -0
- data/spec/config/symmetric-encryption.yml +83 -0
- data/spec/config/test_new.iv +4 -0
- data/spec/config/test_new.key +2 -0
- data/spec/config/test_secondary_1.iv +1 -0
- data/spec/config/test_secondary_1.key +2 -0
- data/spec/spec_helper.rb +8 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MGE2MWE3OGJkYjIyOGEyNTgyMDdjNTQ4YWUzYmM3MjhkMzkzNDRkNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWQ3YzYzMzc5ZjQ0Y2I5MmU0ZWE1NjRhMjM1MzY5NWE4MDM4NTEzNg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTExZDViYzQ0NzI1NzAyOTBiNzJlMzUyMmZhYTg2ZGJjNTA5MDFiYTk4ODZj
|
10
|
+
ZDBhZTMwMzZmNzMwN2FlZTNhYzkwYzE3Y2FiMTdiZjA2Mzg3NGY5MzA3NTYz
|
11
|
+
NDhhYjJkMDAxMzVkMGU5ZTViMTM3MGMyM2E1NGU5NGNmNjYyYTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmJmMTUzOTMzYjI2Y2U2ZTFhNDM2ZGVhZjdjYTE5M2EzNGRhYmUwM2I5MTEw
|
14
|
+
OTAxMGMwNWM3OWUwYWM5MTFjODJiMDkyMTQxM2YwZDEwMTZiNGQyMjk5M2Q3
|
15
|
+
ZWI2NGI0M2ZlZjdlMzYyMjQ3MzY0OTViYzkyNGJmNzc0ZDE2NmE=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2014 M. Scott Ford
|
190
|
+
Some portions copyright 2012, 2013, 2014 Reid Morrison
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# EncryptedSearchAttributes
|
2
|
+
|
3
|
+
Auto populates encrypted fields that are designed for searching
|
4
|
+
|
5
|
+
Encrypting a field makes it very difficult to perform a case insensitive search for the columns data. This gem normalizes the text before encrypted it and storing it in a search column. The current normalization method is to convert the text to all lowercase.
|
6
|
+
|
7
|
+
This gem is intended to be used with the symmetric-encryption gem. It assumes that a `encrypted_search_attribute` column exists for the encrypted attribute.
|
8
|
+
|
9
|
+
## Example
|
10
|
+
|
11
|
+
Let's assume we have the following ActiveRecord model defined.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
class Widget < ActiveRecord::Base
|
15
|
+
attr_encrypted :name
|
16
|
+
attr_encrypted_search :name
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
This would require the database schema to look something like this.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
create_table "patients", :force => true do |t|
|
24
|
+
t.string "encrypted_name"
|
25
|
+
t.string "encrypted_search_name"
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
Add this line to your application's Gemfile:
|
32
|
+
|
33
|
+
gem 'encrypted_search_attributes'
|
34
|
+
|
35
|
+
And then execute:
|
36
|
+
|
37
|
+
$ bundle
|
38
|
+
|
39
|
+
Or install it yourself as:
|
40
|
+
|
41
|
+
$ gem install encrypted_search_attributes
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
TODO: Write usage instructions here
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it ( http://github.com/mscottford/encrypted_search_attributes/fork )
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'encrypted_search_attributes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "encrypted_search_attributes"
|
8
|
+
spec.version = EncryptedSearchAttributes::VERSION
|
9
|
+
spec.authors = ["M. Scott Ford"]
|
10
|
+
spec.email = ["scott@corgibytes.com"]
|
11
|
+
spec.summary = %q{Auto populates encrypted fields that are designed for searching}
|
12
|
+
spec.description = %q{Encrypting a field makes it very difficult to perform a case insensitive search for the columns data. This gem normalizes the text before encrypted it and storing it in a search column. The current normalization method is to convert the text to all lowercase.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "Apache License v2.0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'symmetric-encryption', '~> 3.3'
|
22
|
+
spec.add_dependency 'activerecord', '~> 3.2.13'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake", '~> 10.1'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
27
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.8'
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
def attr_encrypted_search(*params)
|
5
|
+
define_attribute_methods rescue nil
|
6
|
+
|
7
|
+
options = params.last.is_a?(Hash) ? params.pop.dup : {}
|
8
|
+
compress = options.delete(:compress) || false
|
9
|
+
type = options.delete(:type) || :string
|
10
|
+
|
11
|
+
raise "Invalid type: #{type.inspect}. Valid types: #{SymmetricEncryption::COERCION_TYPES.inspect}" unless SymmetricEncryption::COERCION_TYPES.include?(type)
|
12
|
+
|
13
|
+
options.each {|option| warn "Ignoring unknown option #{option.inspect} supplied to attr_encrypted_search with #{params.inspect}"}
|
14
|
+
|
15
|
+
if const_defined?(:EncryptedSearchAttributes, _search_ancestors = false)
|
16
|
+
mod = const_get(:EncryptedSearchAttributes)
|
17
|
+
else
|
18
|
+
mod = const_set(:EncryptedSearchAttributes, Module.new)
|
19
|
+
include mod
|
20
|
+
end
|
21
|
+
|
22
|
+
params.each do |attribute|
|
23
|
+
mod.module_eval(<<-ENCRYPTEDSEARCH, __FILE__, __LINE__ + 1)
|
24
|
+
def #{attribute}=(value)
|
25
|
+
if value
|
26
|
+
self.encrypted_search_#{attribute} = ::SymmetricEncryption.encrypt(value.downcase,false,#{compress},:#{type})
|
27
|
+
end
|
28
|
+
super(value)
|
29
|
+
end
|
30
|
+
ENCRYPTEDSEARCH
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
db_config_file = File.expand_path('../../config/database.yml', __FILE__)
|
4
|
+
encryption_config_file = File.expand_path('../../config/symmetric-encryption.yml', __FILE__)
|
5
|
+
|
6
|
+
ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(db_config_file)).result)
|
7
|
+
ActiveRecord::Base.establish_connection('test')
|
8
|
+
|
9
|
+
ActiveRecord::Schema.define(version: 0) do
|
10
|
+
create_table :widgets, force: true do |t|
|
11
|
+
t.string :encrypted_name
|
12
|
+
t.string :encrypted_search_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Widget < ActiveRecord::Base
|
17
|
+
attr_encrypted :name
|
18
|
+
attr_encrypted_search :name
|
19
|
+
end
|
20
|
+
|
21
|
+
SymmetricEncryption.load!(encryption_config_file, 'test')
|
22
|
+
|
23
|
+
# Initialize the database connection
|
24
|
+
config = YAML.load(ERB.new(File.new(db_config_file).read).result)['test']
|
25
|
+
|
26
|
+
Widget.establish_connection(config)
|
27
|
+
|
28
|
+
describe 'attr_encrypted_search' do
|
29
|
+
it 'sets encrypted search field on initialization' do
|
30
|
+
widget = Widget.new(name: 'Test Value')
|
31
|
+
|
32
|
+
search_value = ::SymmetricEncryption.encrypt('test value')
|
33
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
34
|
+
|
35
|
+
widget.save!
|
36
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
37
|
+
|
38
|
+
widget.reload
|
39
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'sets the encrypted search field on creation' do
|
43
|
+
widget = Widget.create!(name: 'Another Test')
|
44
|
+
|
45
|
+
search_value = ::SymmetricEncryption.encrypt('another test')
|
46
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
47
|
+
|
48
|
+
widget.reload
|
49
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'sets encrypted search field on assignment' do
|
53
|
+
widget = Widget.create!
|
54
|
+
|
55
|
+
widget.name = 'Something Else'
|
56
|
+
|
57
|
+
search_value = ::SymmetricEncryption.encrypt('something else')
|
58
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
59
|
+
|
60
|
+
widget.save!
|
61
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
62
|
+
|
63
|
+
widget.reload
|
64
|
+
expect(widget.encrypted_search_name).to eq(search_value)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'preserves attr_encrypted functionality' do
|
68
|
+
widget = Widget.create!(name: 'Anything')
|
69
|
+
expect(widget.name).to eq('Anything')
|
70
|
+
expect(widget.encrypted_name).to eq(::SymmetricEncryption.encrypt('Anything'))
|
71
|
+
|
72
|
+
widget.reload
|
73
|
+
expect(widget.encrypted_name).to eq(::SymmetricEncryption.encrypt('Anything'))
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Test Config with multiple keys
|
3
|
+
#
|
4
|
+
---
|
5
|
+
test:
|
6
|
+
# Test RSA Key, DO NOT use this RSA key, generate a new one using
|
7
|
+
# openssl genrsa 2048
|
8
|
+
# Or use the rails generator to create a new config file as described in the readme
|
9
|
+
private_rsa_key: |
|
10
|
+
-----BEGIN RSA PRIVATE KEY-----
|
11
|
+
MIIEpAIBAAKCAQEAxIL9H/jYUGpA38v6PowRSRJEo3aNVXULNM/QNRpx2DTf++KH
|
12
|
+
6DcuFTFcNSSSxG9n4y7tKi755be8N0uwCCuOzvXqfWmXYjbLwK3Ib2vm0btpHyvA
|
13
|
+
qxgqeJOOCxKdW/cUFLWn0tACUcEjVCNfWEGaFyvkOUuR7Ub9KfhbW9cZO3BxZMUf
|
14
|
+
IPGlHl/gWyf484sXygd+S7cpDTRRzo9RjG74DwfE0MFGf9a1fTkxnSgeOJ6asTOy
|
15
|
+
fp9tEToUlbglKaYGpOGHYQ9TV5ZsyJ9jRUyb4SP5wK2eK6dHTxTcHvT03kD90Hv4
|
16
|
+
WeKIXv3WOjkwNEyMdpnJJfSDb5oquQvCNi7ZSQIDAQABAoIBAQCbzR7TUoBugU+e
|
17
|
+
ICLvpC2wOYOh9kRoFLwlyv3QnH7WZFWRZzFJszYeJ1xr5etXQtyjCnmOkGAg+WOI
|
18
|
+
k8GlOKOpAuA/PpB/leJFiYL4lBwU/PmDdTT0cdx6bMKZlNCeMW8CXGQKiFDOcMqJ
|
19
|
+
0uGtH5YD+RChPIEeFsJxnC8SyZ9/t2ra7XnMGiCZvRXIUDSEIIsRx/mOymJ7bL+h
|
20
|
+
Lbp46IfXf6ZuIzwzoIk0JReV/r+wdmkAVDkrrMkCmVS4/X1wN/Tiik9/yvbsh/CL
|
21
|
+
ztC55eSIEjATkWxnXfPASZN6oUfQPEveGH3HzNjdncjH/Ho8FaNMIAfFpBhhLPi9
|
22
|
+
nG5sbH+BAoGBAOdoUyVoAA/QUa3/FkQaa7Ajjehe5MR5k6VtaGtcxrLiBjrNR7x+
|
23
|
+
nqlZlGvWDMiCz49dgj+G1Qk1bbYrZLRX/Hjeqy5dZOGLMfgf9eKUmS1rDwAzBMcj
|
24
|
+
M9jnnJEBx8HIlNzaR6wzp3GMd0rrccs660A8URvzkgo9qNbvMLq9vyUtAoGBANll
|
25
|
+
SY1Iv9uaIz8klTXU9YzYtsfUmgXzw7K8StPdbEbo8F1J3JPJB4D7QHF0ObIaSWuf
|
26
|
+
suZqLsvWlYGuJeyX2ntlBN82ORfvUdOrdrbDlmPyj4PfFVl0AK3U3Ai374DNrjKR
|
27
|
+
hF6YFm4TLDaJhUjeV5C43kbE1N2FAMS9LYtPJ44NAoGAFDGHZ/E+aCLerddfwwun
|
28
|
+
MBS6MnftcLPHTZ1RimTrNfsBXipBw1ItWEvn5s0kCm9X24PmdNK4TnhqHYaF4DL5
|
29
|
+
ZjbQK1idEA2Mi8GGPIKJJ2x7P6I0HYiV4qy7fe/w1ZlCXE90B7PuPbtrQY9wO7Ll
|
30
|
+
ipJ45X6I1PnyfOcckn8yafUCgYACtPAlgjJhWZn2v03cTbqA9nHQKyV/zXkyUIXd
|
31
|
+
/XPLrjrP7ouAi5A8WuSChR/yx8ECRgrEM65Be3qBEtoGCB4AS1G0NcigM6qhKBFi
|
32
|
+
VS0aMXr3+V8argcUIwJaWW/x+p2go48yXlJpLHPweeXe8mXEt4iM+QZte6p2yKQ4
|
33
|
+
h9PGQQKBgQCqSydmXBnXGIVTp2sH/2GnpxLYnDBpcJE0tM8bJ42HEQQgRThIChsn
|
34
|
+
PnGA91G9MVikYapgI0VYBHQOTsz8rTIUzsKwXG+TIaK+W84nxH5y6jUkjqwxZmAz
|
35
|
+
r1URaMAun2PfAB4g2N/kEZTExgeOGqXjFhvvjdzl97ux2cTyZhaTXg==
|
36
|
+
-----END RSA PRIVATE KEY-----
|
37
|
+
|
38
|
+
ciphers:
|
39
|
+
# Current / Newest Symmetric Encryption Key
|
40
|
+
#
|
41
|
+
# To manually generate new keys once this file has been generated:
|
42
|
+
# require 'symmetric_encryption'
|
43
|
+
# SymmetricEncryption.generate_symmetric_key_files('this_file_name.yml', 'production')
|
44
|
+
-
|
45
|
+
key_filename: spec/config/test_new.key
|
46
|
+
iv_filename: spec/config/test_new.iv
|
47
|
+
cipher_name: aes-128-cbc
|
48
|
+
# Base64 encode encrypted data without newlines
|
49
|
+
encoding: base64strict
|
50
|
+
version: 2
|
51
|
+
always_add_header: true
|
52
|
+
|
53
|
+
# Prior Symmetric Encryption Key specified in environment variable
|
54
|
+
-
|
55
|
+
# Base64 encoded and RSA encrypted, encryption key
|
56
|
+
# encrypted_key can be used for retrieving the encrypted key from a source
|
57
|
+
# other than a local file.
|
58
|
+
#
|
59
|
+
# Example:
|
60
|
+
# # An environment variable:
|
61
|
+
# encrypted_key: <%= ENV['KEY'] %>
|
62
|
+
#
|
63
|
+
# NOTE: Do not put the encrypted key directly in this file. It is only here
|
64
|
+
# for testing purposes
|
65
|
+
encrypted_key: <%= 'xFAsZ73PThktyo76PoNQGYnjCJUAd4+Yaz71bO5FajshXsbjkfZjjvbK9hxzWLr+C7X67hcrTypVHB1Rw0De8lRDqexlc87sTx1wtlz70lOvTBXt9Lv4sbJNLxacuqk545LIJpgK02Dq7FGzACV3jb3Yk+QQngiscETYM6PyiuFpReFB0qFOgCSLeBJsXAdNdqkEZggl8PL+lGDueDGeKUng+Ic/AFWPhJGYkk3xV++AGwUFXdDQeuHllxmV9WlzriHnDwzbfugkfGaRjWn808VXrv9Jgf2yRy++gOYUvRnjZ1ltOgXUEEmBVF2Uvhu+zs6C/D4cb1mkR7911M5naA==' %>
|
66
|
+
# For testing purposes only, the above RSA encrypted key is just:
|
67
|
+
# key: ABCDEF1234567890
|
68
|
+
iv: 1234567890ABCDEF
|
69
|
+
cipher_name: aes-128-cbc
|
70
|
+
# Base64 encode encrypted data without newlines
|
71
|
+
encoding: base64strict
|
72
|
+
version: 1
|
73
|
+
always_add_header: false
|
74
|
+
|
75
|
+
# First Symmetric Encryption Key
|
76
|
+
-
|
77
|
+
key_filename: spec/config/test_secondary_1.key
|
78
|
+
iv_filename: spec/config/test_secondary_1.iv
|
79
|
+
cipher_name: aes-128-cbc
|
80
|
+
# Base64 encode encrypted data
|
81
|
+
encoding: base64
|
82
|
+
version: 0
|
83
|
+
always_add_header: false
|
@@ -0,0 +1 @@
|
|
1
|
+
N�ʤd�X0��Vܝ���5]��$�y؎��=���Mq>�pP����gY���}+_�0�)�6���{�F�gN���#��Gρ'�۪���Q�I-�+f���S��~�x|t����C~�h�t8l��V簤�z+�ĺO�MKz"7N��?<�?ր�5B��D�<mq!ۺcHwHcH��?�]/_�s���[��iH^:��ٰ�{V�|�C~y\�B�y Fc,8i�5��r�ƍQ<첀
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: encrypted_search_attributes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- M. Scott Ford
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: symmetric-encryption
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.13
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.13
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.8
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.8
|
97
|
+
description: Encrypting a field makes it very difficult to perform a case insensitive
|
98
|
+
search for the columns data. This gem normalizes the text before encrypted it and
|
99
|
+
storing it in a search column. The current normalization method is to convert the
|
100
|
+
text to all lowercase.
|
101
|
+
email:
|
102
|
+
- scott@corgibytes.com
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- .gitignore
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- encrypted_search_attributes.gemspec
|
113
|
+
- lib/encrypted_search_attributes.rb
|
114
|
+
- lib/encrypted_search_attributes/extensions/active_record/base.rb
|
115
|
+
- lib/encrypted_search_attributes/version.rb
|
116
|
+
- spec/acceptance/attr_encrypted_search_spec.rb
|
117
|
+
- spec/config/database.yml
|
118
|
+
- spec/config/symmetric-encryption.yml
|
119
|
+
- spec/config/test_new.iv
|
120
|
+
- spec/config/test_new.key
|
121
|
+
- spec/config/test_secondary_1.iv
|
122
|
+
- spec/config/test_secondary_1.key
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: ''
|
125
|
+
licenses:
|
126
|
+
- Apache License v2.0
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.1.11
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Auto populates encrypted fields that are designed for searching
|
148
|
+
test_files:
|
149
|
+
- spec/acceptance/attr_encrypted_search_spec.rb
|
150
|
+
- spec/config/database.yml
|
151
|
+
- spec/config/symmetric-encryption.yml
|
152
|
+
- spec/config/test_new.iv
|
153
|
+
- spec/config/test_new.key
|
154
|
+
- spec/config/test_secondary_1.iv
|
155
|
+
- spec/config/test_secondary_1.key
|
156
|
+
- spec/spec_helper.rb
|