vault 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +42 -0
- data/CHANGELOG.md +7 -0
- data/README.md +8 -2
- data/lib/vault/api/kv.rb +1 -1
- data/lib/vault/api/sys.rb +1 -0
- data/lib/vault/api/sys/mount.rb +5 -0
- data/lib/vault/api/sys/namespace.rb +85 -0
- data/lib/vault/client.rb +9 -0
- data/lib/vault/configurable.rb +1 -0
- data/lib/vault/defaults.rb +7 -0
- data/lib/vault/version.rb +1 -1
- data/vault.gemspec +5 -5
- metadata +23 -23
- data/.travis.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba24586cf3aedc6a9b72b5ea495aa3870e24961d2e1c28f26588efe89c3e778
|
4
|
+
data.tar.gz: 875863da0975071d886d611d18d5dc6ff0605c1bee4e3263e1b1dcc9b70100c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 060e894c68bc091fce76db59f9d9d17afce399b6b7f2e1df7944f560998cfe0c3d691d28902db279cc18301a35779e4f16fd03263a07f42835669b4eb1c10165
|
7
|
+
data.tar.gz: 4595750556960ac6e9bcc0d69615ae1dff5a993e85e0bd63f8320234089bdfdecda2863ea8c092e9bd1ebac9ef50b3e15d426a1e5449c2974f8cdd053b7abeb7
|
@@ -0,0 +1,42 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
references:
|
4
|
+
images:
|
5
|
+
ubuntu: &UBUNTU_IMAGE ubuntu-1604:201903-01
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
machine:
|
10
|
+
image: *UBUNTU_IMAGE
|
11
|
+
parameters:
|
12
|
+
ruby-version:
|
13
|
+
type: string
|
14
|
+
vault-version:
|
15
|
+
type: string
|
16
|
+
steps:
|
17
|
+
- checkout
|
18
|
+
- run:
|
19
|
+
name: Install vault
|
20
|
+
command: |
|
21
|
+
curl -sLo vault.zip https://releases.hashicorp.com/vault/<< parameters.vault-version >>/vault_<< parameters.vault-version >>_linux_amd64.zip
|
22
|
+
unzip vault.zip
|
23
|
+
mkdir -p ~/bin
|
24
|
+
mv vault ~/bin
|
25
|
+
export PATH="~/bin:$PATH"
|
26
|
+
- run:
|
27
|
+
name: Run tests
|
28
|
+
command: |
|
29
|
+
export VAULT_VERSION=<< parameters.vault-version >>
|
30
|
+
rvm use << parameters.ruby-version >> --install --binary --fuzzy
|
31
|
+
bundle install --jobs=3 --retry=3 --path=vendor/bundle
|
32
|
+
bundle exec rake
|
33
|
+
|
34
|
+
workflows:
|
35
|
+
run-tests:
|
36
|
+
jobs:
|
37
|
+
- test:
|
38
|
+
matrix:
|
39
|
+
parameters:
|
40
|
+
ruby-version: ["2.2", "2.3", "2.4"]
|
41
|
+
vault-version: ["1.0.3", "1.1.5", "1.2.4", "1.3.0"]
|
42
|
+
name: test-ruby-<< matrix.ruby-version >>-vault-<< matrix.vault-version >>
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Vault Ruby Changelog
|
2
2
|
|
3
|
+
## v0.13.1 (April 28, 2020)
|
4
|
+
|
5
|
+
IMPROVEMENTS
|
6
|
+
|
7
|
+
- Added support for defining a namespace when initializing the client, as well as options for changing the namespace via method.
|
8
|
+
- Added support for sys/namespaces API. Ability to Get, Create, Delete, and List namespaces has been provided.
|
9
|
+
|
3
10
|
## v0.12.0 (August 14, 2018)
|
4
11
|
|
5
12
|
IMPROVEMENTS
|
data/README.md
CHANGED
@@ -28,6 +28,8 @@ Start a Vault client:
|
|
28
28
|
```ruby
|
29
29
|
Vault.address = "http://127.0.0.1:8200" # Also reads from ENV["VAULT_ADDR"]
|
30
30
|
Vault.token = "abcd-1234" # Also reads from ENV["VAULT_TOKEN"]
|
31
|
+
# Optional - if using the Namespace enterprise feature
|
32
|
+
# Vault.namespace = "my-namespace" # Also reads from ENV["VAULT_NAMESPACE"]
|
31
33
|
|
32
34
|
Vault.sys.mounts #=> { :secret => #<struct Vault::Mount type="generic", description="generic secret storage"> }
|
33
35
|
```
|
@@ -43,6 +45,8 @@ Vault.configure do |config|
|
|
43
45
|
|
44
46
|
# The token to authenticate with Vault, also read as ENV["VAULT_TOKEN"]
|
45
47
|
config.token = "abcd-1234"
|
48
|
+
# Optional - if using the Namespace enterprise feature
|
49
|
+
# config.namespace = "my-namespace" # Also reads from ENV["VAULT_NAMESPACE"]
|
46
50
|
|
47
51
|
# Proxy connection information, also read as ENV["VAULT_PROXY_(thing)"]
|
48
52
|
config.proxy_address = "..."
|
@@ -85,7 +89,8 @@ And if you want to authenticate with a `AWS EC2` :
|
|
85
89
|
# Export VAULT_ADDR to ENV then
|
86
90
|
# Get the pkcs7 value from AWS
|
87
91
|
signature = `curl http://169.254.169.254/latest/dynamic/instance-identity/pkcs7`
|
88
|
-
|
92
|
+
iam_role = `curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
|
93
|
+
vault_token = Vault.auth.aws_ec2(iam_role, signature, nil)
|
89
94
|
vault_client = Vault::Client.new(address: ENV["VAULT_ADDR"], token: vault_token.auth.client_token)
|
90
95
|
```
|
91
96
|
|
@@ -208,7 +213,8 @@ Development
|
|
208
213
|
|
209
214
|
Important Notes:
|
210
215
|
|
211
|
-
- **All new features must include test coverage.** At a bare minimum, Unit tests are required. It is preferred if you include
|
216
|
+
- **All new features must include test coverage.** At a bare minimum, Unit tests are required. It is preferred if you include integration tests as well.
|
212
217
|
- **The tests must be be idempotent.** The HTTP calls made during a test should be able to be run over and over.
|
213
218
|
- **Tests are order independent.** The default RSpec configuration randomizes the test order, so this should not be a problem.
|
214
219
|
- **Integration tests require Vault** Vault must be available in the path for the integration tests to pass.
|
220
|
+
- **In order to be considered an integration test:** The test MUST use the `vault_test_client` or `vault_redirect_test_client` as the client. This spawns a process, or uses an already existing process from another test, to run against.
|
data/lib/vault/api/kv.rb
CHANGED
data/lib/vault/api/sys.rb
CHANGED
data/lib/vault/api/sys/mount.rb
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Vault
|
2
|
+
class Namespace < Response
|
3
|
+
# @!attribute [r] id
|
4
|
+
# ID of the namespace
|
5
|
+
# @return [String]
|
6
|
+
field :id
|
7
|
+
|
8
|
+
# @!attribute [r] path
|
9
|
+
# Path of the namespace, includes parent paths if nested.
|
10
|
+
# @return [String]
|
11
|
+
field :path
|
12
|
+
end
|
13
|
+
|
14
|
+
class Sys
|
15
|
+
# List all namespaces in a given scope. Ignores nested namespaces.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# Vault.sys.namespaces #=> { :foo => #<struct Vault::Namespace id="xxxx1", path="foo/" }
|
19
|
+
#
|
20
|
+
# @return [Hash<Symbol, Namespace>]
|
21
|
+
#
|
22
|
+
# NOTE: Due to a bug in Vault Enterprise, to be fixed soon, this method CAN return a pure JSON string if a scoping namespace is provided.
|
23
|
+
def namespaces(scoped=nil)
|
24
|
+
path = ["v1", scoped, "sys", "namespaces"].compact
|
25
|
+
json = client.list(path.join("/"))
|
26
|
+
json = json[:data] if json[:data]
|
27
|
+
if json[:key_info]
|
28
|
+
json = json[:key_info]
|
29
|
+
hash = {}
|
30
|
+
json.each do |k,v|
|
31
|
+
hash[k.to_s.chomp("/").to_sym] = Namespace.decode(v)
|
32
|
+
end
|
33
|
+
hash
|
34
|
+
else
|
35
|
+
json
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create a namespace. Nests the namespace if a namespace header is provided.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Vault.sys.create_namespace("foo")
|
43
|
+
#
|
44
|
+
# @param [String] namespace
|
45
|
+
# the potential path of the namespace, without any parent path provided
|
46
|
+
#
|
47
|
+
# @return [true]
|
48
|
+
def create_namespace(namespace)
|
49
|
+
client.put("/v1/sys/namespaces/#{namespace}", {})
|
50
|
+
return true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Delete a namespace. Raises an error if the namespace provided is not empty.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# Vault.sys.delete_namespace("foo")
|
57
|
+
#
|
58
|
+
# @param [String] namespace
|
59
|
+
# the path of the namespace to be deleted
|
60
|
+
#
|
61
|
+
# @return [true]
|
62
|
+
def delete_namespace(namespace)
|
63
|
+
client.delete("/v1/sys/namespaces/#{namespace}")
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Retrieve a namespace by path.
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# Vault.sys.get_namespace("foo")
|
71
|
+
#
|
72
|
+
# @param [String] namespace
|
73
|
+
# the path of the namespace ot be retrieved
|
74
|
+
#
|
75
|
+
# @return [Namespace]
|
76
|
+
def get_namespace(namespace)
|
77
|
+
json = client.get("/v1/sys/namespaces/#{namespace}")
|
78
|
+
if data = json.dig(:data)
|
79
|
+
Namespace.decode(data)
|
80
|
+
else
|
81
|
+
json
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/vault/client.rb
CHANGED
@@ -16,6 +16,9 @@ module Vault
|
|
16
16
|
# The name of the header used to hold the Vault token.
|
17
17
|
TOKEN_HEADER = "X-Vault-Token".freeze
|
18
18
|
|
19
|
+
# The name of the header used to hold the Namespace.
|
20
|
+
NAMESPACE_HEADER = "X-Vault-Namespace".freeze
|
21
|
+
|
19
22
|
# The name of the header used to hold the wrapped request ttl.
|
20
23
|
WRAP_TTL_HEADER = "X-Vault-Wrap-TTL".freeze
|
21
24
|
|
@@ -255,6 +258,12 @@ module Vault
|
|
255
258
|
headers[TOKEN_HEADER] ||= token
|
256
259
|
end
|
257
260
|
|
261
|
+
# Add the Vault Namespace header - users could still override this on a
|
262
|
+
# per-request basis
|
263
|
+
if !namespace.nil?
|
264
|
+
headers[NAMESPACE_HEADER] ||= namespace
|
265
|
+
end
|
266
|
+
|
258
267
|
# Add headers
|
259
268
|
headers.each do |key, value|
|
260
269
|
request.add_field(key, value)
|
data/lib/vault/configurable.rb
CHANGED
data/lib/vault/defaults.rb
CHANGED
data/lib/vault/version.rb
CHANGED
data/vault.gemspec
CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_runtime_dependency "aws-sigv4"
|
22
|
+
spec.add_runtime_dependency "aws-sigv4", "1.1.1"
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler"
|
25
|
-
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
25
|
+
spec.add_development_dependency "pry", "~> 0.13.1"
|
26
26
|
spec.add_development_dependency "rake", "~> 12.0"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.5"
|
28
|
-
spec.add_development_dependency "yard"
|
29
|
-
spec.add_development_dependency "webmock", "~>
|
28
|
+
spec.add_development_dependency "yard", "~> 0.9.24"
|
29
|
+
spec.add_development_dependency "webmock", "~> 3.8.3"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sigv4
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.1.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.13.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.13.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,30 +84,30 @@ dependencies:
|
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.9.24
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.9.24
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.8.3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.8.3
|
111
111
|
description: Vault is a Ruby API client for interacting with a Vault server.
|
112
112
|
email:
|
113
113
|
- sethvargo@gmail.com
|
@@ -115,9 +115,9 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- ".circleci/config.yml"
|
118
119
|
- ".gitignore"
|
119
120
|
- ".rspec"
|
120
|
-
- ".travis.yml"
|
121
121
|
- CHANGELOG.md
|
122
122
|
- Gemfile
|
123
123
|
- LICENSE
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/vault/api/sys/leader.rb
|
142
142
|
- lib/vault/api/sys/lease.rb
|
143
143
|
- lib/vault/api/sys/mount.rb
|
144
|
+
- lib/vault/api/sys/namespace.rb
|
144
145
|
- lib/vault/api/sys/policy.rb
|
145
146
|
- lib/vault/api/sys/seal.rb
|
146
147
|
- lib/vault/client.rb
|
@@ -178,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
179
|
- !ruby/object:Gem::Version
|
179
180
|
version: '0'
|
180
181
|
requirements: []
|
181
|
-
|
182
|
-
rubygems_version: 2.7.6
|
182
|
+
rubygems_version: 3.1.2
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Vault is a Ruby API client for interacting with a Vault server.
|
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
dist: trusty
|
2
|
-
sudo: false
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
|
6
|
-
env:
|
7
|
-
- VAULT_VERSION=0.11.4
|
8
|
-
- VAULT_VERSION=0.10.4
|
9
|
-
- VAULT_VERSION=0.9.6
|
10
|
-
- VAULT_VERSION=0.8.3
|
11
|
-
- VAULT_VERSION=0.7.3
|
12
|
-
- VAULT_VERSION=0.6.5
|
13
|
-
- VAULT_VERSION=0.5.3
|
14
|
-
|
15
|
-
before_install:
|
16
|
-
- curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
|
17
|
-
- unzip vault.zip
|
18
|
-
- mkdir -p ~/bin
|
19
|
-
- mv vault ~/bin
|
20
|
-
- export PATH="~/bin:$PATH"
|
21
|
-
|
22
|
-
branches:
|
23
|
-
only:
|
24
|
-
- master
|
25
|
-
|
26
|
-
rvm:
|
27
|
-
- 2.2
|
28
|
-
- 2.3
|
29
|
-
- 2.4
|