key-vault 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/key-vault.gemspec +25 -0
- data/lib/key_vault.rb +24 -0
- data/lib/key_vault/railtie.rb +11 -0
- data/lib/key_vault/version.rb +3 -0
- data/spec/key_vault_spec.rb +47 -0
- data/tasks/key_vault.rake +18 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 816aa733f4ad496a11e4a094995ed4059d003908
|
4
|
+
data.tar.gz: e97281577ba360206d58691fb16a6a0b6c2438d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21f33769159bdb4b6a633688549bd077464855d858a4969f2b67a58ae17cc22ab7d7fb4efec603357db8986d3673b02edf6e9c25e6365a9a4e5112984231df78
|
7
|
+
data.tar.gz: c495ab1a4b221b4a418cdc72f3fdd3004add75a40af1ac6fe8f54e798e5867fd7abea26f90ad8be1e8ddbdf138b2948005f11ffe156aecd5550311959d769da9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Redbubble Pty Ltd
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# KeyVault
|
2
|
+
|
3
|
+
KeyVault manages all your secrets so they don't have to live in the repo.
|
4
|
+
|
5
|
+
Currently only works with Rails 3+.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'key-vault', require: 'key_vault'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install key-vault
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Simply put all secrets that shouldn't be checked into your repo into
|
24
|
+
|
25
|
+
config/key_vault.yml
|
26
|
+
|
27
|
+
in your rails app. Then use
|
28
|
+
|
29
|
+
KeyVault[:key]
|
30
|
+
|
31
|
+
it. For example, with a file that contains
|
32
|
+
|
33
|
+
session_secret: this-is-super-secret
|
34
|
+
|
35
|
+
you can use
|
36
|
+
|
37
|
+
AppName::Application.config.secret_token = KeyVault[:session_secret]
|
38
|
+
|
39
|
+
to set your session secret token.
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/key-vault.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'key_vault/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "key-vault"
|
8
|
+
spec.version = KeyVault::VERSION
|
9
|
+
spec.authors = ["redbubble"]
|
10
|
+
spec.email = ["developers@redbubble.com"]
|
11
|
+
spec.description = %q{Put all your secrets in the vault}
|
12
|
+
spec.summary = %q{KeyVault manages all your secrets so they don't have to live in the repo}
|
13
|
+
spec.homepage = "https://github.com/redbubble/key-vault"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rails"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
data/lib/key_vault.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
require "key_vault/version"
|
4
|
+
require "key_vault/railtie"
|
5
|
+
|
6
|
+
module KeyVault
|
7
|
+
class << self
|
8
|
+
def [](key)
|
9
|
+
if values.has_key?(key)
|
10
|
+
values[key]
|
11
|
+
else
|
12
|
+
raise ArgumentError, "'#{key}' not found in key_vault.yml"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def keys
|
17
|
+
values.keys
|
18
|
+
end
|
19
|
+
|
20
|
+
def values
|
21
|
+
@values ||= YAML.load(IO.read(Rails.root + "config/key_vault.yml")).symbolize_keys
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require './lib/key_vault'
|
2
|
+
|
3
|
+
describe KeyVault do
|
4
|
+
|
5
|
+
describe '.[]' do
|
6
|
+
before do
|
7
|
+
KeyVault.stub values: { session_secret: "secret" }
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the value from key_vault.yml' do
|
11
|
+
KeyVault[:session_secret].should == "secret"
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'raises an error if the key wasnt found' do
|
15
|
+
expect { KeyVault[:unknown] }.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.keys' do
|
20
|
+
before do
|
21
|
+
KeyVault.stub values: { session_secret: "secret" }
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the list of keys' do
|
25
|
+
KeyVault.keys.should include(:session_secret)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.values' do
|
30
|
+
before do
|
31
|
+
Rails.stub root: '/tmp/'
|
32
|
+
FileUtils.mkdir '/tmp/config'
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
FileUtils.rm_rf '/tmp/config'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'reads key_vault.yml in the rails config folder' do
|
40
|
+
File.open('/tmp/config/key_vault.yml', 'w') do |f|
|
41
|
+
f.puts({ session_secret: 'super_secret' }.to_yaml)
|
42
|
+
end
|
43
|
+
|
44
|
+
KeyVault.values[:session_secret].should == 'super_secret'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :key_vault do
|
2
|
+
|
3
|
+
desc "Check if the given set of keys matches the key vault keys on the local file system"
|
4
|
+
task check: :environment do
|
5
|
+
local_keys = ENV['LOCAL_KEYS'].split(',').map(&:to_sym)
|
6
|
+
server_keys = KeyVault.keys
|
7
|
+
|
8
|
+
missing_local = server_keys - local_keys
|
9
|
+
if !missing_local.empty?
|
10
|
+
puts "\e[30m\e[43mWarning: The local key_vault.yml file is missing: #{missing_local.join(', ')}\e[39m\e[49m"
|
11
|
+
end
|
12
|
+
|
13
|
+
missing_server = local_keys - server_keys
|
14
|
+
if !missing_server.empty?
|
15
|
+
fail "The server key_vault.yml file is missing: #{missing_server.join(', ')}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: key-vault
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- redbubble
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Put all your secrets in the vault
|
70
|
+
email:
|
71
|
+
- developers@redbubble.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- key-vault.gemspec
|
82
|
+
- lib/key_vault.rb
|
83
|
+
- lib/key_vault/railtie.rb
|
84
|
+
- lib/key_vault/version.rb
|
85
|
+
- spec/key_vault_spec.rb
|
86
|
+
- tasks/key_vault.rake
|
87
|
+
homepage: https://github.com/redbubble/key-vault
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.1.11
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: KeyVault manages all your secrets so they don't have to live in the repo
|
111
|
+
test_files:
|
112
|
+
- spec/key_vault_spec.rb
|