vault 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 +7 -0
- data/.gitignore +41 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +362 -0
- data/README.md +80 -54
- data/Rakefile +4 -40
- data/lib/vault.rb +33 -46
- data/lib/vault/api.rb +9 -0
- data/lib/vault/api/auth_token.rb +90 -0
- data/lib/vault/api/help.rb +23 -0
- data/lib/vault/api/logical.rb +66 -0
- data/lib/vault/api/secret.rb +23 -0
- data/lib/vault/api/sys.rb +24 -0
- data/lib/vault/api/sys/audit.rb +60 -0
- data/lib/vault/api/sys/auth.rb +58 -0
- data/lib/vault/api/sys/init.rb +46 -0
- data/lib/vault/api/sys/leader.rb +25 -0
- data/lib/vault/api/sys/lease.rb +51 -0
- data/lib/vault/api/sys/mount.rb +75 -0
- data/lib/vault/api/sys/policy.rb +76 -0
- data/lib/vault/api/sys/seal.rb +49 -0
- data/lib/vault/client.rb +285 -0
- data/lib/vault/configurable.rb +48 -0
- data/lib/vault/defaults.rb +68 -0
- data/lib/vault/errors.rb +48 -0
- data/lib/vault/request.rb +19 -0
- data/lib/vault/response.rb +20 -0
- data/lib/vault/version.rb +1 -6
- data/vault.gemspec +25 -0
- metadata +97 -98
- data/MIT-LICENSE +0 -20
- data/lib/vault/associations.rb +0 -39
- data/lib/vault/attribute_accessors.rb +0 -29
- data/lib/vault/bulk_attributes.rb +0 -17
- data/lib/vault/dirty.rb +0 -37
- data/lib/vault/finders.rb +0 -24
- data/lib/vault/persistance.rb +0 -47
- data/lib/vault/properties.rb +0 -68
- data/lib/vault/scoping.rb +0 -64
- data/lib/vault/storage.rb +0 -4
- data/lib/vault/storage/in_memory_store.rb +0 -14
- data/lib/vault/storage/yaml_store.rb +0 -52
- data/lib/vault/validations.rb +0 -13
- data/spec/active_model_compliance_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -8
- data/spec/support/helpers.rb +0 -16
- data/spec/support/storage_api.rb +0 -14
- data/spec/vault/associations_spec.rb +0 -73
- data/spec/vault/finders_spec.rb +0 -69
- data/spec/vault/persistance_spec.rb +0 -126
- data/spec/vault/properties_spec.rb +0 -59
- data/spec/vault/scoping_spec.rb +0 -53
- data/spec/vault/storage/in_memory_store_spec.rb +0 -5
- data/spec/vault/storage/yaml_store_spec.rb +0 -29
- data/spec/vault_spec.rb +0 -33
data/lib/vault/errors.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Vault
|
2
|
+
class VaultError < RuntimeError; end
|
3
|
+
|
4
|
+
class MissingTokenError < VaultError
|
5
|
+
def initialize
|
6
|
+
super <<-EOH
|
7
|
+
Missing Vault token! I cannot make requests to Vault without a token. Please
|
8
|
+
set a Vault token:
|
9
|
+
|
10
|
+
Vault.token = "42d1dee5-eb6e-102c-8d23-cc3ba875da51"
|
11
|
+
|
12
|
+
Please refer to the documentation for more examples.
|
13
|
+
EOH
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class HTTPConnectionError < VaultError
|
18
|
+
attr_reader :address
|
19
|
+
|
20
|
+
def initialize(address)
|
21
|
+
@address = address
|
22
|
+
|
23
|
+
super <<-EOH
|
24
|
+
The Vault server at `#{address}' is not currently
|
25
|
+
accepting connections. Please ensure that the server is running an that your
|
26
|
+
authentication information is correct.
|
27
|
+
EOH
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class HTTPError < VaultError
|
32
|
+
attr_reader :address, :code, :errors
|
33
|
+
|
34
|
+
def initialize(address, code, errors = [])
|
35
|
+
@address, @code, @errors = address, code.to_i, errors
|
36
|
+
errors = errors.map { |error| " * #{error}" }
|
37
|
+
|
38
|
+
super <<-EOH
|
39
|
+
The Vault server at `#{address}' responded with a #{code}.
|
40
|
+
Any additional information the server supplied is shown below:
|
41
|
+
|
42
|
+
#{errors.join("\n").rstrip}
|
43
|
+
|
44
|
+
Please refer to the documentation for help.
|
45
|
+
EOH
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Vault
|
2
|
+
class Request
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def to_s
|
11
|
+
"#<#{self.class.name}>"
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
def inspect
|
16
|
+
"#<#{self.class.name}:0x#{"%x" % (self.object_id << 1)}>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vault
|
2
|
+
module Response
|
3
|
+
def self.new(*members)
|
4
|
+
Struct.new(*members) do
|
5
|
+
def self.decode(object)
|
6
|
+
self.new(*object.values_at(*self.members))
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"#<#{self.class.name}>"
|
11
|
+
end
|
12
|
+
|
13
|
+
def inspect
|
14
|
+
data = self.members.map { |m| "@#{m}=#{self.public_send(m).inspect}" }.join(", ")
|
15
|
+
"#<#{self.class.name} #{data}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/vault/version.rb
CHANGED
data/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 "vault/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vault"
|
8
|
+
spec.version = Vault::VERSION
|
9
|
+
spec.authors = ["Seth Vargo"]
|
10
|
+
spec.email = ["sethvargo@gmail.com"]
|
11
|
+
spec.licenses = ["MPLv2"]
|
12
|
+
|
13
|
+
spec.summary = "Vault is a Ruby API client for interacting with a Vault server."
|
14
|
+
spec.description = spec.summary
|
15
|
+
spec.homepage = "https://github.com/hashicorp/vault-ruby"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
25
|
+
end
|
metadata
CHANGED
@@ -1,119 +1,118 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
6
|
+
authors:
|
7
|
+
- Seth Vargo
|
13
8
|
autorequire:
|
14
|
-
bindir:
|
9
|
+
bindir: exe
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2015-04-28 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.9'
|
20
|
+
type: :development
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- - "
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rspec
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
38
35
|
prerelease: false
|
39
|
-
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
47
48
|
type: :development
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
description: Vault is a Ruby API client for interacting with a Vault server.
|
56
|
+
email:
|
57
|
+
- sethvargo@gmail.com
|
51
58
|
executables: []
|
52
|
-
|
53
59
|
extensions: []
|
54
|
-
|
55
|
-
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE
|
56
69
|
- README.md
|
57
|
-
- MIT-LICENSE
|
58
|
-
files:
|
59
70
|
- Rakefile
|
60
|
-
- lib/vault/associations.rb
|
61
|
-
- lib/vault/attribute_accessors.rb
|
62
|
-
- lib/vault/bulk_attributes.rb
|
63
|
-
- lib/vault/dirty.rb
|
64
|
-
- lib/vault/finders.rb
|
65
|
-
- lib/vault/persistance.rb
|
66
|
-
- lib/vault/properties.rb
|
67
|
-
- lib/vault/scoping.rb
|
68
|
-
- lib/vault/storage/in_memory_store.rb
|
69
|
-
- lib/vault/storage/yaml_store.rb
|
70
|
-
- lib/vault/storage.rb
|
71
|
-
- lib/vault/validations.rb
|
72
|
-
- lib/vault/version.rb
|
73
71
|
- lib/vault.rb
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
72
|
+
- lib/vault/api.rb
|
73
|
+
- lib/vault/api/auth_token.rb
|
74
|
+
- lib/vault/api/help.rb
|
75
|
+
- lib/vault/api/logical.rb
|
76
|
+
- lib/vault/api/secret.rb
|
77
|
+
- lib/vault/api/sys.rb
|
78
|
+
- lib/vault/api/sys/audit.rb
|
79
|
+
- lib/vault/api/sys/auth.rb
|
80
|
+
- lib/vault/api/sys/init.rb
|
81
|
+
- lib/vault/api/sys/leader.rb
|
82
|
+
- lib/vault/api/sys/lease.rb
|
83
|
+
- lib/vault/api/sys/mount.rb
|
84
|
+
- lib/vault/api/sys/policy.rb
|
85
|
+
- lib/vault/api/sys/seal.rb
|
86
|
+
- lib/vault/client.rb
|
87
|
+
- lib/vault/configurable.rb
|
88
|
+
- lib/vault/defaults.rb
|
89
|
+
- lib/vault/errors.rb
|
90
|
+
- lib/vault/request.rb
|
91
|
+
- lib/vault/response.rb
|
92
|
+
- lib/vault/version.rb
|
93
|
+
- vault.gemspec
|
94
|
+
homepage: https://github.com/hashicorp/vault-ruby
|
95
|
+
licenses:
|
96
|
+
- MPLv2
|
97
|
+
metadata: {}
|
92
98
|
post_install_message:
|
93
99
|
rdoc_options: []
|
94
|
-
|
95
|
-
require_paths:
|
100
|
+
require_paths:
|
96
101
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
99
104
|
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
106
109
|
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
|
109
|
-
- 0
|
110
|
-
version: "0"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
111
112
|
requirements: []
|
112
|
-
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.2.3
|
115
115
|
signing_key:
|
116
|
-
specification_version:
|
117
|
-
summary:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Vault is a Ruby API client for interacting with a Vault server.
|
118
118
|
test_files: []
|
119
|
-
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010-* Nicolás Sanguinetti
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/vault/associations.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Vault
|
2
|
-
module Associations
|
3
|
-
def has_many(name, klass_name=name.to_s.classify, foreign_key="#{self.to_s.underscore.singularize}_key")
|
4
|
-
define_method name do
|
5
|
-
model = klass_name.is_a?(Class) ? klass_name : self.class.const_get(klass_name)
|
6
|
-
HasManyProxy.new(self, model, foreign_key, foreign_key => key)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def belongs_to(name, klass_name=name.to_s.classify)
|
11
|
-
foreign_key = "#{name}_key"
|
12
|
-
|
13
|
-
property(foreign_key)
|
14
|
-
|
15
|
-
define_method name do
|
16
|
-
model = klass_name.is_a?(Class) ? klass_name : self.class.const_get(klass_name)
|
17
|
-
model[send(foreign_key)]
|
18
|
-
end
|
19
|
-
|
20
|
-
define_method "#{name}=" do |object|
|
21
|
-
send("#{foreign_key}=", object.key)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class HasManyProxy < Scoping::Scope
|
26
|
-
def initialize(owner, model, foreign_key, conditions={})
|
27
|
-
super(model, conditions)
|
28
|
-
@owner = owner
|
29
|
-
@foreign_key = foreign_key
|
30
|
-
end
|
31
|
-
|
32
|
-
def <<(object)
|
33
|
-
object.send("#{@foreign_key}=", @owner.key)
|
34
|
-
object.save
|
35
|
-
self
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Vault
|
2
|
-
module AttributeAccessors
|
3
|
-
def initialize(*)
|
4
|
-
@_attributes = attributes_from_model_properties
|
5
|
-
super
|
6
|
-
end
|
7
|
-
|
8
|
-
def write_attribute(name, value)
|
9
|
-
@_attributes[name] = value
|
10
|
-
end
|
11
|
-
|
12
|
-
def read_attribute(name)
|
13
|
-
@_attributes[name]
|
14
|
-
end
|
15
|
-
|
16
|
-
def attributes
|
17
|
-
@_attributes
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def attributes_from_model_properties
|
23
|
-
self.class.properties.inject(HashWithIndifferentAccess.new) do |props, prop|
|
24
|
-
props[prop.name] = prop.default
|
25
|
-
props
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Vault
|
2
|
-
module BulkAttributes
|
3
|
-
def initialize(attrs={})
|
4
|
-
update(attrs)
|
5
|
-
changed_attributes.clear
|
6
|
-
end
|
7
|
-
|
8
|
-
def update(attrs={})
|
9
|
-
attrs.each do |key, value|
|
10
|
-
method = "#{key}="
|
11
|
-
__send__(method, value)
|
12
|
-
end
|
13
|
-
|
14
|
-
self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|