vault-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/Rakefile +7 -9
- data/lib/vault/encrypted_model.rb +18 -3
- data/lib/vault/rails/version.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +28 -0
- data/spec/dummy/log/test.log +14 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16a5e1ecf9b12ecf7d936d9e7fa571b9dc724bf
|
4
|
+
data.tar.gz: 57414fcaf32bba53dc44edc018ec4979f0c44089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628d4e1c1560b0787a669679e1ced7f9e85578376aca525d3f17164e7e0306b19e767a0fcfd498071d9920daac2f20a5caf68f551afc71b2e2b1d9fec19fff1c
|
7
|
+
data.tar.gz: 98dcd9cbf08e4dfe0a2783455768944f48ba07a70ff7d02fc998b7cb4baa7aa731846a34a3245d2dba92c44fac2f04eed9fef3139b51ab7f6d094cf01a9c40cf
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
Vault Rails
|
1
|
+
Vault Rails [![Build Status](https://secure.travis-ci.org/hashicorp/vault-rails.svg?branch=master)](http://travis-ci.org/hashicorp/vault-rails)
|
2
2
|
===========
|
3
|
-
[![Build Status](https://secure.travis-ci.org/hashicorp/vault-rails.png?branch=master)](http://travis-ci.org/hashicorp/vault-rails)
|
4
3
|
|
5
4
|
Vault is the official Rails plugin for interacting with [Vault](https://vaultproject.io) by HashiCorp.
|
6
5
|
|
@@ -20,7 +19,7 @@ Quick Start
|
|
20
19
|
```ruby
|
21
20
|
require "vault/rails"
|
22
21
|
|
23
|
-
Vault
|
22
|
+
Vault.configure do |vault|
|
24
23
|
vault.application = "my_app"
|
25
24
|
|
26
25
|
# Default: ENV["VAULT_ADDR"]
|
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
begin
|
2
3
|
require 'bundler/setup'
|
3
4
|
rescue LoadError
|
@@ -6,13 +7,10 @@ end
|
|
6
7
|
|
7
8
|
Bundler::GemHelper.install_tasks
|
8
9
|
|
9
|
-
|
10
|
+
# Extract tasks for interacting with the dummy application
|
11
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
12
|
+
load "rails/tasks/engine.rake"
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
t.pattern = 'test/**/*_test.rb'
|
15
|
-
t.verbose = false
|
16
|
-
end
|
17
|
-
|
18
|
-
task default: :test
|
14
|
+
require "rspec/core/rake_task"
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
task default: :spec
|
@@ -40,6 +40,9 @@ module Vault
|
|
40
40
|
encrypted = read_attribute(:#{encrypted_column})
|
41
41
|
return nil if encrypted.nil?
|
42
42
|
|
43
|
+
self.class._vault_ensure_mounted!("#{path}")
|
44
|
+
self.class._vault_ensure_key!("#{path}", "#{key}")
|
45
|
+
|
43
46
|
path = File.join("v1", "#{path}", "decrypt", "#{key}")
|
44
47
|
response = Vault.put(path, JSON.fast_generate(
|
45
48
|
ciphertext: encrypted,
|
@@ -51,6 +54,9 @@ module Vault
|
|
51
54
|
end
|
52
55
|
|
53
56
|
def #{column}=(value)
|
57
|
+
self.class._vault_ensure_mounted!("#{path}")
|
58
|
+
self.class._vault_ensure_key!("#{path}", "#{key}")
|
59
|
+
|
54
60
|
path = File.join("v1", "#{path}", "encrypt", "#{key}")
|
55
61
|
response = Vault.put(path, JSON.fast_generate(
|
56
62
|
plaintext: Base64.encode64(value),
|
@@ -67,8 +73,6 @@ module Vault
|
|
67
73
|
end
|
68
74
|
EOH
|
69
75
|
|
70
|
-
_vault_ensure_mounted!(path)
|
71
|
-
_vault_ensure_key!(path, key)
|
72
76
|
_vault_attributes.store(column.to_sym, true)
|
73
77
|
|
74
78
|
self
|
@@ -85,10 +89,17 @@ module Vault
|
|
85
89
|
#
|
86
90
|
# @return [true]
|
87
91
|
def _vault_ensure_mounted!(path)
|
92
|
+
@_vault_mounts ||= {}
|
93
|
+
return true if @_vault_mounts.key?(path)
|
94
|
+
|
88
95
|
mounts = Vault.sys.mounts
|
89
|
-
|
96
|
+
if mounts[path.to_s.chomp("/").to_sym]
|
97
|
+
@_vault_mounts[path] = true
|
98
|
+
return true
|
99
|
+
end
|
90
100
|
|
91
101
|
Vault.sys.mount(path, :transit)
|
102
|
+
@_vault_mounts[path] = true
|
92
103
|
return true
|
93
104
|
end
|
94
105
|
|
@@ -96,13 +107,17 @@ module Vault
|
|
96
107
|
#
|
97
108
|
# @return [true]
|
98
109
|
def _vault_ensure_key!(path, key)
|
110
|
+
@_vault_keys ||= {}
|
111
|
+
|
99
112
|
key_path = File.join("v1", path, "keys", key)
|
113
|
+
return true if @_vault_keys.key?(key_path)
|
100
114
|
|
101
115
|
begin
|
102
116
|
Vault.get(key_path)
|
103
117
|
rescue => e
|
104
118
|
raise if e.code != 404
|
105
119
|
Vault.post(key_path, nil)
|
120
|
+
@_vault_keys[key_path] = true
|
106
121
|
end
|
107
122
|
|
108
123
|
return true
|
data/lib/vault/rails/version.rb
CHANGED
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
Binary file
|
Binary file
|
@@ -122,3 +122,31 @@ Migrating to CreatePeople (20150428220101)
|
|
122
122
|
[1m[35m (0.1ms)[0m begin transaction
|
123
123
|
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?)[0m [["ssn_encrypted", "vault:v0:m6f94GbtEQb1WIc3H67n4vQwC0p+vnOYAT8COCZ/fYQLXePJMNCu"], ["created_at", "2015-04-28 23:44:27.223470"], ["updated_at", "2015-04-28 23:44:27.223470"]]
|
124
124
|
[1m[35m (0.9ms)[0m commit transaction
|
125
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
126
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["ssn_encrypted", "vault:v0:qxouo09RQjtBRqVKmKapa3a/U7zTB/odoT6h9+mwH0Mwn3dHXxU/"], ["created_at", "2015-05-03 20:00:55.530325"], ["updated_at", "2015-05-03 20:00:55.530325"]]
|
127
|
+
[1m[36m (0.7ms)[0m [1mcommit transaction[0m
|
128
|
+
[1m[35m (0.1ms)[0m begin transaction
|
129
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?)[0m [["ssn_encrypted", "vault:v0:n/XCr3mC8fEwqfPVyy2QdFIcv3Csosry9ppLfpv1yyyzdA2NyaOw"], ["created_at", "2015-05-03 20:00:55.538344"], ["updated_at", "2015-05-03 20:00:55.538344"]]
|
130
|
+
[1m[35m (0.7ms)[0m commit transaction
|
131
|
+
[1m[36mPerson Load (0.2ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1[0m [["id", 2]]
|
132
|
+
[1m[35m (0.1ms)[0m begin transaction
|
133
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?)[0m [["cc_encrypted", "vault:v0:r02c5cKhoKbfamYlqxllfbo+RJ21c99CWh2kkuqq0DZKB3dusgMMq0lmgQc="], ["created_at", "2015-05-03 20:00:55.549422"], ["updated_at", "2015-05-03 20:00:55.549422"]]
|
134
|
+
[1m[35m (0.7ms)[0m commit transaction
|
135
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
136
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["cc_encrypted", "vault:v0:OmsnAmkgOjrx9O7r1lYvuA6PuHPcioKVHlZCPSNYdILZfwb2sOuhxqmb6XA="], ["created_at", "2015-05-03 20:00:55.552834"], ["updated_at", "2015-05-03 20:00:55.552834"]]
|
137
|
+
[1m[36m (0.7ms)[0m [1mcommit transaction[0m
|
138
|
+
[1m[35mPerson Load (0.1ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 4]]
|
139
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
140
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["cc_encrypted", "vault:v0:ZWw4VVfGhXhjBaLJu3RLZRQfQ5njTQ3UgIRNTFCJbgroQw6e2UX6ZSVPMqk="], ["created_at", "2015-05-13 22:42:13.557668"], ["updated_at", "2015-05-13 22:42:13.557668"]]
|
141
|
+
[1m[36m (0.7ms)[0m [1mcommit transaction[0m
|
142
|
+
[1m[35m (0.1ms)[0m begin transaction
|
143
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?)[0m [["ssn_encrypted", "vault:v0:c+b+bkgvOvsVuhBGKCNeoIs+/IGpeKtaN1gmn9nWTAbKRQOUVOzT"], ["created_at", "2015-05-13 22:42:13.576030"], ["updated_at", "2015-05-13 22:42:13.576030"]]
|
144
|
+
[1m[35m (0.8ms)[0m commit transaction
|
145
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
146
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["cc_encrypted", "vault:v0:xQGXFichQPr1EQJk10Q+WgxFYBFrgvM8WU8aYBYaaHoiKYVmhI4MDOigR4c="], ["created_at", "2015-05-13 22:42:13.579756"], ["updated_at", "2015-05-13 22:42:13.579756"]]
|
147
|
+
[1m[36m (0.7ms)[0m [1mcommit transaction[0m
|
148
|
+
[1m[35mPerson Load (0.3ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 3]]
|
149
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
150
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["ssn_encrypted", "vault:v0:xdqQIbXzzT+3qJLC3/YyCam0/aoG5vddjdYB1m72M7XVRWAtfSHI"], ["created_at", "2015-05-13 22:42:13.590222"], ["updated_at", "2015-05-13 22:42:13.590222"]]
|
151
|
+
[1m[36m (0.8ms)[0m [1mcommit transaction[0m
|
152
|
+
[1m[35mPerson Load (0.1ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 4]]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
2
|
+
[1m[35mSQL (0.5ms)[0m INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["cc_encrypted", "vault:v0:Ba4Qx8HIuaNkX0zJVuAKphrvFxLtZkAxpaJFGQHZp1ulldzBEZliFa0l5HY="], ["created_at", "2015-05-03 20:03:11.475271"], ["updated_at", "2015-05-03 20:03:11.475271"]]
|
3
|
+
[1m[36m (2.0ms)[0m [1mcommit transaction[0m
|
4
|
+
[1m[35mPerson Load (0.2ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 1]]
|
5
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
6
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["cc_encrypted", "vault:v0:M32QnURvlJw0NEm6gTVFxyU/jQLtfrVcmJqMAr+aE1uV9k+nvKmiwlleHhg="], ["created_at", "2015-05-03 20:03:11.487005"], ["updated_at", "2015-05-03 20:03:11.487005"]]
|
7
|
+
[1m[36m (0.8ms)[0m [1mcommit transaction[0m
|
8
|
+
[1m[35m (0.1ms)[0m begin transaction
|
9
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?)[0m [["ssn_encrypted", "vault:v0:6jtVQHOgdBJPmWJemdRoLVG60IJjPZRyRPpWCmveZeynVKuH1Wqs"], ["created_at", "2015-05-03 20:03:11.499248"], ["updated_at", "2015-05-03 20:03:11.499248"]]
|
10
|
+
[1m[35m (0.7ms)[0m commit transaction
|
11
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
12
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["ssn_encrypted", "vault:v0:j/w8lqcte/98jwwa3ZR1XivRaeXV65SRmSpjChafAZQ3kT9xuMFc"], ["created_at", "2015-05-03 20:03:11.502515"], ["updated_at", "2015-05-03 20:03:11.502515"]]
|
13
|
+
[1m[36m (0.6ms)[0m [1mcommit transaction[0m
|
14
|
+
[1m[35mPerson Load (0.1ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 4]]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -134,7 +134,9 @@ files:
|
|
134
134
|
- spec/dummy/db/development.sqlite3
|
135
135
|
- spec/dummy/db/migrate/20150428220101_create_people.rb
|
136
136
|
- spec/dummy/db/schema.rb
|
137
|
+
- spec/dummy/db/test.sqlite3
|
137
138
|
- spec/dummy/log/development.log
|
139
|
+
- spec/dummy/log/test.log
|
138
140
|
- spec/dummy/public/404.html
|
139
141
|
- spec/dummy/public/422.html
|
140
142
|
- spec/dummy/public/500.html
|
@@ -194,7 +196,9 @@ test_files:
|
|
194
196
|
- spec/dummy/db/development.sqlite3
|
195
197
|
- spec/dummy/db/migrate/20150428220101_create_people.rb
|
196
198
|
- spec/dummy/db/schema.rb
|
199
|
+
- spec/dummy/db/test.sqlite3
|
197
200
|
- spec/dummy/log/development.log
|
201
|
+
- spec/dummy/log/test.log
|
198
202
|
- spec/dummy/public/404.html
|
199
203
|
- spec/dummy/public/422.html
|
200
204
|
- spec/dummy/public/500.html
|