attribute_queryable_encrypted 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "active_support", ">= 3.0"
22
+ s.add_dependency "activesupport", ">= 3.0.1"
23
23
  s.add_development_dependency "rspec"
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module AttributeQueryableEncrypted
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/readme.md CHANGED
@@ -27,26 +27,34 @@ Example:
27
27
 
28
28
  ActiveRecord:
29
29
  -------------
30
- ActiveRecord users gain a query method for their prefix digest column:
30
+ ActiveRecord users gain a `find_all_by_[prefix]_[attribute]` query method for their prefix digest column:
31
31
 
32
32
  HiddenValue.find_all_by_prefix_data("This is ")
33
33
  # => [#<HiddenValue id: 1, encrypted_data: "MWE2ODg0ZTVmNTA2M2I3MTZmMWQxZGI3NzA0MjgyMzRj...", prefix_data_digest: "MTgyODBlMWFkNGZiMjAyZTc5Y2FiYTcxODZhYTg1OWM3OGNhOWI...">, #<HiddenValue id: 2, encrypted_data: "WQxZGI3NzANTA2M2I3MTZmMj0MjgyMzRMWE2ODg0ZTVm...", prefix_data_digest: "MTgyODBlMWFkNGZiMjAyZTc5Y2FiYTcxODZhYTg1OWM3OGNhOWI...">]
34
34
 
35
35
  The returned records - a subset of the full table - can then be iterated over to find an exact match.
36
36
 
37
- A convenience method is provided to do this for you - note that it requires an attribute getter method (but not necessarily a database column) that provides a cleartext match for your query argument:
37
+ A convenience method is provided to do this for you - `find_by_[attribute]`. Note that it requires an attribute getter method (but not necessarily a database column) that provides a cleartext match for your query argument:
38
38
 
39
- HiddenValue.find_by_prefix_data("This is a string")
39
+ HiddenValue.find_by_data("This is a string")
40
40
  # => #<HiddenValue id: 1, encrypted_data: "MWE2ODg0ZTVmNTA2M2I3MTZmMWQxZGI3NzA0MjgyMzRj...", prefix_data_digest: "MTgyODBlMWFkNGZiMjAyZTc5Y2FiYTcxODZhYTg1OWM3OGNhOWI...">
41
41
 
42
42
  You'll need to create an appropriately-named prefix digest column on your own.
43
43
 
44
+ AttributeQueryableEncrypted is automatically included into ActiveRecord::Base when the gem is installed. To use, just specify the columns you want:
45
+
46
+ class HiddenValue < ActiveRecord::Base
47
+ attr_encrypted :data, :key => { |record| SiteKey + record.salt }
48
+ attribute_queryable_encrypted :data, :length => "35%", :suffix => "queryable"
49
+ end
50
+
51
+ Your :data accessor (provided here by attr_encrypted) should exist prior to defining the queryable accessor.
44
52
 
45
53
  Options:
46
54
  --------
47
55
  * :length - an integer value length, or percentage expressed as a string ("72%"). Default is "50%".
48
56
  * :prefix - prefix name for the storage accessor. Default is "prefix"
49
- * :suffix - suffix name for the storage accessor. Defuault is "suffix"
57
+ * :suffix - suffix name for the storage accessor. Default is "digest"
50
58
  * :encode - Base64 encode the digest hash, suitable for database persistence. Default is false.
51
59
  * :stretches - an integer number of iterations through the digest algorithm. More will reduce the ease of a precomputed attack. Default is 3.
52
60
  * :key - an optional key to salt the digest algorithm. Default is nil.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Burton
@@ -18,7 +18,7 @@ date: 2011-11-17 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: active_support
21
+ name: activesupport
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -28,7 +28,8 @@ dependencies:
28
28
  segments:
29
29
  - 3
30
30
  - 0
31
- version: "3.0"
31
+ - 1
32
+ version: 3.0.1
32
33
  type: :runtime
33
34
  version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency