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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9438c9a75fea09add2a02f0e329c07c6e61a6dd
4
- data.tar.gz: b8cc22f3996a1dfcdd7c31c6b9058808797b582f
3
+ metadata.gz: f16a5e1ecf9b12ecf7d936d9e7fa571b9dc724bf
4
+ data.tar.gz: 57414fcaf32bba53dc44edc018ec4979f0c44089
5
5
  SHA512:
6
- metadata.gz: 128979046ab618c07a0a3827245ed028ad831db6c256eeefa936dd2e82414857fe2a0063061cbc4e3308f6145528b64994016d9b8345e21e29c2b19da8cb43b4
7
- data.tar.gz: 97c3b798691bd65214936eb3b7738d04f23a73307aa4cb63db2a96027f8ad1e447cccf141c7d03a66f6e711b66a343402875dd622eb09c40bc5f6ef56dd467ab
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::Rails.configure do |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
- require 'rake/testtask'
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
- Rake::TestTask.new(:test) do |t|
12
- t.libs << 'lib'
13
- t.libs << 'test'
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
- return true if mounts[path.to_s.chomp("/").to_sym]
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
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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.serve_static_assets = true
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.
@@ -122,3 +122,31 @@ Migrating to CreatePeople (20150428220101)
122
122
   (0.1ms) begin transaction
123
123
  SQL (0.2ms) INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["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
   (0.9ms) commit transaction
125
+  (0.1ms) begin transaction
126
+ SQL (0.4ms) 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
+  (0.7ms) commit transaction
128
+  (0.1ms) begin transaction
129
+ SQL (0.3ms) INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["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
+  (0.7ms) commit transaction
131
+ Person Load (0.2ms) SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 2]]
132
+  (0.1ms) begin transaction
133
+ SQL (0.3ms) INSERT INTO "people" ("cc_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["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
+  (0.7ms) commit transaction
135
+  (0.0ms) begin transaction
136
+ SQL (0.2ms) 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
+  (0.7ms) commit transaction
138
+ Person Load (0.1ms) SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 4]]
139
+  (0.1ms) begin transaction
140
+ SQL (0.4ms) 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
+  (0.7ms) commit transaction
142
+  (0.1ms) begin transaction
143
+ SQL (0.4ms) INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["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
+  (0.8ms) commit transaction
145
+  (0.1ms) begin transaction
146
+ SQL (0.3ms) 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
+  (0.7ms) commit transaction
148
+ Person Load (0.3ms) SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 3]]
149
+  (0.1ms) begin transaction
150
+ SQL (0.3ms) 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
+  (0.8ms) commit transaction
152
+ Person Load (0.1ms) SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 4]]
@@ -0,0 +1,14 @@
1
+  (0.1ms) begin transaction
2
+ SQL (0.5ms) 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
+  (2.0ms) commit transaction
4
+ Person Load (0.2ms) SELECT "people".* FROM "people" WHERE "people"."id" = ? LIMIT 1 [["id", 1]]
5
+  (0.1ms) begin transaction
6
+ SQL (0.3ms) 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
+  (0.8ms) commit transaction
8
+  (0.1ms) begin transaction
9
+ SQL (0.3ms) INSERT INTO "people" ("ssn_encrypted", "created_at", "updated_at") VALUES (?, ?, ?) [["ssn_encrypted", "vault:v0:6jtVQHOgdBJPmWJemdRoLVG60IJjPZRyRPpWCmveZeynVKuH1Wqs"], ["created_at", "2015-05-03 20:03:11.499248"], ["updated_at", "2015-05-03 20:03:11.499248"]]
10
+  (0.7ms) commit transaction
11
+  (0.0ms) begin transaction
12
+ SQL (0.2ms) 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
+  (0.6ms) commit transaction
14
+ Person Load (0.1ms) 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.0
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-01 00:00:00.000000000 Z
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