sequel_vault 0.1 → 0.2

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
  SHA1:
3
- metadata.gz: 9fcd1e2440b221cea5020dd2f48270ad299cc22c
4
- data.tar.gz: 23a8b0f2216268942dc6671a9d73a3415bf8359c
3
+ metadata.gz: 79908bf231a085221e910b96b7345983e900a794
4
+ data.tar.gz: ce9c51ff401740d8b402dae1edf45c7aa323b991
5
5
  SHA512:
6
- metadata.gz: c3557360f3bf786d794faaedf627b2c44f1e0a10aa85b879e86d767ed52e0d203a8402193358208dea5ecf6832a9b8a546c4137cd47293f28b510647d505c588
7
- data.tar.gz: f4f389d1b62102304ea49ab7ab4b9d38d937997b7f5c6e306c7f62165149e60ba4792bd8dc5095478c9f247154dee53c6494971acc125d53a0ebd88dd2d18c6e
6
+ metadata.gz: df113a38e57794ac31a830f01ad5b0a65ad9970b5f89c1bda85bc592516849704ad101c75e95b77756fbd07b4c76a48492967636ddf7072a487fbf6c708427ca
7
+ data.tar.gz: 7953a1f131303b5f2eb28edf48d183c2ee255b76bb7530403e3577c44fc75a85dcee7ad0191c025e58f64e28485741722c5cb69522df15a2efbb57cca4056e69
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Sequel-vault
2
+
3
+ Use [fernet](https://github.com/fernet/fernet-rb) to encrypt columns values in your Sequel database
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ class AWSCreds < Sequel::Model
9
+ # attrs :access_key_id, ::access_key_id_digest, :secret_access_key, :secret_access_key_digest :region, :name
10
+ plugin :vault
11
+ vault_attributes ['Fernet key','...'], :access_key_id, :secret_access_key
12
+ end
13
+ ```
data/lib/sequel_vault.rb CHANGED
@@ -22,8 +22,11 @@ module Sequel
22
22
  end
23
23
 
24
24
  define_method("#{attr}=") do |plain|
25
- cypher = encrypt(keys, plain) unless plain.nil?
25
+ return if plain.nil?
26
+ cypher = encrypt(keys, plain)
27
+ digest = OpenSSL::HMAC.digest('sha512', keys.first, plain)
26
28
  super(cypher)
29
+ send("#{attr}_digest=", digest)
27
30
  end
28
31
  end
29
32
  end
data/sequel_vault.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
14
  gem.name = "sequel_vault"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = '0.1'
16
+ gem.version = '0.2'
17
17
 
18
18
  gem.add_runtime_dependency 'sequel', '~> 4.21', '>= 4.21.0'
19
19
  gem.add_runtime_dependency 'fernet', '~> 2.1', '>= 2.1'
@@ -6,7 +6,7 @@ describe Sequel::Plugins::Vault do
6
6
  let(:klass) do
7
7
  Class.new(Sequel::Model(db[:vm])) do
8
8
  set_primary_key :id
9
- set_columns([:id, :secret])
9
+ set_columns([:id, :secret, :secret_digest])
10
10
 
11
11
  plugin :vault
12
12
  end
@@ -18,6 +18,7 @@ describe Sequel::Plugins::Vault do
18
18
  end
19
19
  let(:sqls) { db.sqls }
20
20
  let(:secret) { "Attack at once." }
21
+ let(:digest) { OpenSSL::HMAC.digest('sha512', keys.first, secret) }
21
22
 
22
23
  it "should encrypt vault attributes" do
23
24
  model.class.vault_attributes(keys, :secret)
@@ -32,4 +33,11 @@ describe Sequel::Plugins::Vault do
32
33
  expect(model.values[:secret]).to be_nil
33
34
  expect(model.secret).to be_nil
34
35
  end
36
+
37
+ it "should write a digest of the value" do
38
+ model.class.vault_attributes(keys, :secret)
39
+ model.secret = secret
40
+ expect(model.values[:secret_digest]).to_not eq(secret)
41
+ expect(model.secret_digest).to eq(digest)
42
+ end
35
43
  end
metadata CHANGED
@@ -1,107 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timothée Peignier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-05 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.21'
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.21.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '4.21'
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.21.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: fernet
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '2.1'
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '2.1'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '2.1'
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '2.1'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rspec
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ~>
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '3.2'
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 3.2.0
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.2'
70
- - - '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 3.2.0
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: simplecov
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ~>
77
+ - - "~>"
78
78
  - !ruby/object:Gem::Version
79
79
  version: 0.9.2
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ~>
84
+ - - "~>"
85
85
  - !ruby/object:Gem::Version
86
86
  version: 0.9.2
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: sqlite3
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ~>
91
+ - - "~>"
92
92
  - !ruby/object:Gem::Version
93
93
  version: '1.3'
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.3.10
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.3'
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: 1.3.10
107
107
  description: Sequel plugins to handle encrypted attributes
@@ -111,11 +111,12 @@ executables: []
111
111
  extensions: []
112
112
  extra_rdoc_files: []
113
113
  files:
114
- - .gitignore
115
- - .rubocop.yml
116
- - .travis.yml
114
+ - ".gitignore"
115
+ - ".rubocop.yml"
116
+ - ".travis.yml"
117
117
  - Gemfile
118
118
  - Gemfile.lock
119
+ - README.md
119
120
  - lib/sequel_vault.rb
120
121
  - sequel_vault.gemspec
121
122
  - spec/sequel_vault_spec.rb
@@ -130,17 +131,17 @@ require_paths:
130
131
  - lib
131
132
  required_ruby_version: !ruby/object:Gem::Requirement
132
133
  requirements:
133
- - - '>='
134
+ - - ">="
134
135
  - !ruby/object:Gem::Version
135
136
  version: '0'
136
137
  required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  requirements:
138
- - - '>='
139
+ - - ">="
139
140
  - !ruby/object:Gem::Version
140
141
  version: '0'
141
142
  requirements: []
142
143
  rubyforge_project:
143
- rubygems_version: 2.0.14
144
+ rubygems_version: 2.4.5
144
145
  signing_key:
145
146
  specification_version: 4
146
147
  summary: Handle attributes encryption.