attr_keyring 0.5.0 → 0.5.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: 89af9cded4db3be4acd36e986f936b489bce666f5c35f458206c2816f0b1e28a
4
- data.tar.gz: 0fbf99ba85dff08dde797e3f8f01d7c5c6492d7c253cc3b81dabcf3e87a51a3d
3
+ metadata.gz: 2fdee29d790a2b8e6f3dedbe485e3f01eafc6ff1c076e6845aac1b321f3b9e18
4
+ data.tar.gz: afc222122dd43e545173656e9c93f7a8f39e1fdf51d403ce857d3796cbedcc50
5
5
  SHA512:
6
- metadata.gz: 0e6225927feb4f6bff64778f978516a9dbdf23f141fd0e2df478f039c12ec948c63f71e0103571ec811385289e02400da2c21fdb7264e7756a46e2bc387048d1
7
- data.tar.gz: 1ef79f040ddb7f720b8cfbb7d8239aea7e6a1ea68f8fb637ae965baa0e7c421d942ffe6c3b5aa9b0fbf688615d42aabf43e047e1c12a681e0d27be14f6e07e79
6
+ metadata.gz: cf8a11057e8802e993ade45fea165daafd6d8d1c6a6719bef14c42391e9f6879b407fa4735c1f97374daa76b4942effc6264d4d431347938b7c6599bebd25cdd
7
+ data.tar.gz: 1c7b23f681512d0bca2ad00d1f4650dc0c84d7b048c5b129ddbd94fe972f42d076a0d22c9c2cdfdeefb573ece82f298a3c8e9e2567deb50481322ed1023355e7
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.lock
@@ -17,11 +17,13 @@ module AttrKeyring
17
17
  target.prepend(
18
18
  Module.new do
19
19
  def reload(options = nil)
20
- super
20
+ instance = super
21
21
 
22
22
  self.class.encrypted_attributes.each do |attribute|
23
23
  clear_decrypted_column_cache(attribute)
24
24
  end
25
+
26
+ instance
25
27
  end
26
28
  end
27
29
  )
@@ -1,3 +1,3 @@
1
1
  module AttrKeyring
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  end
data/lib/keyring/key.rb CHANGED
@@ -5,26 +5,17 @@ module Keyring
5
5
  def initialize(id, key, key_size)
6
6
  @id = Integer(id)
7
7
  @key_size = key_size
8
- @encryption_key, @signing_key = parse(key)
8
+ @encryption_key, @signing_key = parse_key(key)
9
9
  end
10
10
 
11
11
  def to_s
12
- "#<AttrKeyring::Key id=#{id.inspect}>"
12
+ "#<Keyring::Key id=#{id.inspect}>"
13
13
  end
14
14
  alias_method :inspect, :to_s
15
15
 
16
- private def parse(key)
16
+ private def parse_key(key)
17
17
  expected_key_size = @key_size * 2
18
-
19
- secret = if key.bytesize == expected_key_size
20
- key
21
- else
22
- begin
23
- Base64.strict_decode64(key)
24
- rescue ArgumentError
25
- Base64.decode64(key)
26
- end
27
- end
18
+ secret = decode_key(key, expected_key_size)
28
19
 
29
20
  raise InvalidSecret, "Secret must be #{expected_key_size} bytes, instead got #{secret.bytesize}" unless secret.bytesize == expected_key_size
30
21
 
@@ -33,5 +24,17 @@ module Keyring
33
24
 
34
25
  [encryption_key, signing_key]
35
26
  end
27
+
28
+ private def decode_key(key, key_size)
29
+ if key.bytesize == key_size
30
+ key
31
+ else
32
+ begin
33
+ Base64.strict_decode64(key)
34
+ rescue ArgumentError
35
+ Base64.decode64(key)
36
+ end
37
+ end
38
+ end
36
39
  end
37
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_keyring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2019-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -176,7 +176,6 @@ files:
176
176
  - ".travis.yml"
177
177
  - CODE_OF_CONDUCT.md
178
178
  - Gemfile
179
- - Gemfile.lock
180
179
  - LICENSE.txt
181
180
  - README.md
182
181
  - Rakefile
@@ -214,8 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
213
  - !ruby/object:Gem::Version
215
214
  version: '0'
216
215
  requirements: []
217
- rubyforge_project:
218
- rubygems_version: 2.7.6
216
+ rubygems_version: 3.0.1
219
217
  signing_key:
220
218
  specification_version: 4
221
219
  summary: Simple encryption-at-rest plugin for ActiveRecord.
data/Gemfile.lock DELETED
@@ -1,101 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- attr_keyring (0.5.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activemodel (5.2.2)
10
- activesupport (= 5.2.2)
11
- activerecord (5.2.2)
12
- activemodel (= 5.2.2)
13
- activesupport (= 5.2.2)
14
- arel (>= 9.0)
15
- activesupport (5.2.2)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- arel (9.0.0)
21
- ast (2.4.0)
22
- attr_vault (2.1.1)
23
- pg (>= 0.18)
24
- sequel (>= 4.13, < 6.0)
25
- awesome_print (1.8.0)
26
- byebug (10.0.2)
27
- coderay (1.1.2)
28
- concurrent-ruby (1.1.4)
29
- docile (1.3.1)
30
- i18n (1.2.0)
31
- concurrent-ruby (~> 1.0)
32
- jaro_winkler (1.5.1)
33
- json (2.1.0)
34
- metaclass (0.0.4)
35
- method_source (0.9.2)
36
- minitest (5.11.3)
37
- minitest-utils (0.4.4)
38
- minitest
39
- mocha (1.7.0)
40
- metaclass (~> 0.0.1)
41
- parallel (1.12.1)
42
- parser (2.5.3.0)
43
- ast (~> 2.4.0)
44
- pg (1.1.3)
45
- powerpack (0.1.2)
46
- pry (0.12.2)
47
- coderay (~> 1.1.0)
48
- method_source (~> 0.9.0)
49
- pry-byebug (3.6.0)
50
- byebug (~> 10.0)
51
- pry (~> 0.10)
52
- pry-meta (0.0.10)
53
- awesome_print
54
- pry
55
- pry-byebug
56
- pry-remote
57
- pry-remote (0.1.8)
58
- pry (~> 0.9)
59
- slop (~> 3.0)
60
- rainbow (3.0.0)
61
- rake (12.3.2)
62
- rubocop (0.61.1)
63
- jaro_winkler (~> 1.5.1)
64
- parallel (~> 1.10)
65
- parser (>= 2.5, != 2.5.1.1)
66
- powerpack (~> 0.1)
67
- rainbow (>= 2.2.2, < 4.0)
68
- ruby-progressbar (~> 1.7)
69
- unicode-display_width (~> 1.4.0)
70
- ruby-progressbar (1.10.0)
71
- sequel (5.15.0)
72
- simplecov (0.16.1)
73
- docile (~> 1.1)
74
- json (>= 1.8, < 3)
75
- simplecov-html (~> 0.10.0)
76
- simplecov-html (0.10.2)
77
- slop (3.6.0)
78
- thread_safe (0.3.6)
79
- tzinfo (1.2.5)
80
- thread_safe (~> 0.1)
81
- unicode-display_width (1.4.0)
82
-
83
- PLATFORMS
84
- ruby
85
-
86
- DEPENDENCIES
87
- activerecord
88
- attr_keyring!
89
- attr_vault
90
- bundler
91
- minitest-utils
92
- mocha
93
- pg
94
- pry-meta
95
- rake
96
- rubocop
97
- sequel
98
- simplecov
99
-
100
- BUNDLED WITH
101
- 1.17.1