vault 0.7.3 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49716b95ff7c1b7e1a0a8a2d453ead50ff87c958
4
- data.tar.gz: feaa17a437a8b90822902c3242bd0cd1d6ad9e82
3
+ metadata.gz: e3e7e070730fb59b0a4378801579c6740b9bbc5c
4
+ data.tar.gz: f1f6131919b6a9d7a8ed7243b5e68634d9c11eaa
5
5
  SHA512:
6
- metadata.gz: 92a96b4abdfd34d4c9432d4ef1e04a4619b855d10c5432d89620f3095b958f4982d188e9251697683cabcf803c112608e645919819068fcd7cb0508474dd01ff
7
- data.tar.gz: 2757bdad26d92299f73ded6cefca605f4f28c528737f6ab790303c61634e15000c1d8ed08fee299bfb5ec5ffcf245884814acd87c91e22d5b85033ded005ea41
6
+ metadata.gz: bfe1a015d324db102786bcc8ccc39c46f88b09bf6316071d1e60c259f901e7624e90c5aac3504fa6be2568721667a9819c78aec65663a61df3a0f6ecd7daf375
7
+ data.tar.gz: 41f677359df9bd70d0e2162108164d334d202a33cd0487e9e828444b713f1f315b283761515282926f2febf2b26e6597632c216b246fc654a018947baae40da9
@@ -1,15 +1,14 @@
1
+ dist: trusty
2
+ sudo: false
1
3
  language: ruby
2
4
  cache: bundler
3
- sudo: false
4
5
 
5
6
  env:
6
- - VAULT_VERSION=0.6.2
7
- - VAULT_VERSION=0.6.1
8
- - VAULT_VERSION=0.6.0
7
+ - VAULT_VERSION=0.6.4
9
8
  - VAULT_VERSION=0.5.3
10
9
 
11
10
  before_install:
12
- - wget -O vault.zip -q https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
11
+ - curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
13
12
  - unzip vault.zip
14
13
  - mkdir ~/bin
15
14
  - mv vault ~/bin
@@ -20,6 +19,6 @@ branches:
20
19
  - master
21
20
 
22
21
  rvm:
23
- - 2.1
24
- - 2.2.5
25
- - 2.3.1
22
+ - 2.2
23
+ - 2.3
24
+ - 2.4
@@ -1,5 +1,26 @@
1
1
  # Vault Ruby Changelog
2
2
 
3
+ ## v0.8.0 (March 3, 2017)
4
+
5
+ BREAKING CHANGES
6
+
7
+ - Use PUT/POST for all functions that involve tokens [GH-117]. For Vault 0.6+,
8
+ this will work as-expected. For older Vault versions, you will need to use an
9
+ older client library which uses the URL instead. This is deprecated in Vault
10
+ because the URL would include the token, thus revealing it in request logs.
11
+ These new methods place the token in the body instead.
12
+
13
+ BUG FIXES
14
+
15
+ - Do not convert arrays in #to_h [GH-125]
16
+ - Prevent mismatched checkout/checkin from the connection pool; this will avoid masking errors that occur on pool checkout.
17
+
18
+ IMPROVEMENTS
19
+
20
+ - Support new init API options [GH-127]
21
+ - Return base64-encoded keys in init response [GH-128]
22
+ - Add support for `#hostname` for specifying SNI hostname to validate [GH-112]
23
+
3
24
  ## v0.7.3 (October 25, 2016)
4
25
 
5
26
  BUG FIXES
@@ -163,6 +163,27 @@ module Vault
163
163
  return secret
164
164
  end
165
165
 
166
+ # Authenticate via the AWS EC2 authentication method. If authentication is
167
+ # successful, the resulting token will be stored on the client and used
168
+ # for future requests.
169
+ #
170
+ # @example
171
+ # Vault.auth.aws_ec2("read-only", "pkcs7", "vault-nonce") #=> #<Vault::Secret lease_id="">
172
+ #
173
+ # @param [String] role
174
+ # @param [String] pkcs7
175
+ # pkcs7 returned by the instance identity document (with line breaks removed)
176
+ # @param [String] nonce
177
+ #
178
+ # @return [Secret]
179
+ def aws_ec2(role, pkcs7, nonce)
180
+ payload = { role: role, pkcs7: pkcs7, nonce: nonce }
181
+ json = client.post('/v1/auth/aws-ec2/login', JSON.fast_generate(payload))
182
+ secret = Secret.decode(json)
183
+ client.token = secret.auth.client_token
184
+ return secret
185
+ end
186
+
166
187
  # Authenticate via a TLS authentication method. If authentication is
167
188
  # successful, the resulting token will be stored on the client and used
168
189
  # for future requests.
@@ -105,10 +105,14 @@ module Vault
105
105
  # Vault.auth_token.lookup_self("abcd-...") #=> #<Vault::Secret lease_id="">
106
106
  #
107
107
  # @param [String] token
108
+ # @param [Hash] options
108
109
  #
109
110
  # @return [Secret]
110
- def lookup(token)
111
- json = client.get("/v1/auth/token/lookup/#{encode_path(token)}")
111
+ def lookup(token, options = {})
112
+ headers = extract_headers!(options)
113
+ json = client.post("/v1/auth/token/lookup", JSON.fast_generate(
114
+ token: token,
115
+ ), headers)
112
116
  return Secret.decode(json)
113
117
  end
114
118
 
@@ -116,10 +120,14 @@ module Vault
116
120
  #
117
121
  # @example
118
122
  # Vault.auth_token.lookup_accessor("acbd-...") #=> #<Vault::Secret lease_id="">
119
- def lookup_accessor(accessor)
123
+ #
124
+ # @param [String] accessor
125
+ # @param [Hash] options
126
+ def lookup_accessor(accessor, options = {})
127
+ headers = extract_headers!(options)
120
128
  json = client.post("/v1/auth/token/lookup-accessor", JSON.fast_generate(
121
129
  accessor: accessor,
122
- ))
130
+ ), headers)
123
131
  return Secret.decode(json)
124
132
  end
125
133
 
@@ -139,19 +147,21 @@ module Vault
139
147
  # @example
140
148
  # Vault.auth_token.renew("abcd-1234") #=> #<Vault::Secret lease_id="">
141
149
  #
142
- # @param [String] id
143
- # the auth id
150
+ # @param [String] token
151
+ # the auth token
144
152
  # @param [Fixnum] increment
145
153
  #
146
154
  # @return [Secret]
147
- def renew(id, increment = 0)
148
- json = client.put("/v1/auth/token/renew/#{id}", JSON.fast_generate(
155
+ def renew(token, increment = 0, options = {})
156
+ headers = extract_headers!(options)
157
+ json = client.put("/v1/auth/token/renew", JSON.fast_generate(
158
+ token: token,
149
159
  increment: increment,
150
- ))
160
+ ), headers)
151
161
  return Secret.decode(json)
152
162
  end
153
163
 
154
- # Renews a lease associated with the callign token.
164
+ # Renews a lease associated with the calling token.
155
165
  #
156
166
  # @example
157
167
  # Vault.auth_token.renew_self #=> #<Vault::Secret lease_id="">
@@ -159,10 +169,11 @@ module Vault
159
169
  # @param [Fixnum] increment
160
170
  #
161
171
  # @return [Secret]
162
- def renew_self(increment = 0)
172
+ def renew_self(increment = 0, options = {})
173
+ headers = extract_headers!(options)
163
174
  json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
164
175
  increment: increment,
165
- ))
176
+ ), headers)
166
177
  return Secret.decode(json)
167
178
  end
168
179
 
@@ -181,41 +192,51 @@ module Vault
181
192
  # @example
182
193
  # Vault.auth_token.revoke_orphan("abcd-1234") #=> true
183
194
  #
184
- # @param [String] id
185
- # the auth id
195
+ # @param [String] token
196
+ # the token to revoke
186
197
  #
187
198
  # @return [true]
188
- def revoke_orphan(id)
189
- client.put("/v1/auth/token/revoke-orphan/#{id}", nil)
199
+ def revoke_orphan(token, options = {})
200
+ headers = extract_headers!(options)
201
+ client.put("/v1/auth/token/revoke-orphan", JSON.fast_generate(
202
+ token: token,
203
+ ), headers)
190
204
  return true
191
205
  end
192
206
 
193
- # Revoke all auth at the given prefix.
207
+ # Revoke exactly the orphans at the id.
194
208
  #
195
209
  # @example
196
- # Vault.auth_token.revoke_prefix("abcd-1234") #=> true
210
+ # Vault.auth_token.revoke_accessor("abcd-1234") #=> true
197
211
  #
198
- # @param [String] prefix
199
- # the prefix to revoke
212
+ # @param [String] accessor
213
+ # the accessor to revoke
200
214
  #
201
215
  # @return [true]
202
- def revoke_prefix(prefix)
203
- client.put("/v1/auth/token/revoke-prefix/#{prefix}", nil)
216
+ def revoke_accessor(accessor, options = {})
217
+ headers = extract_headers!(options)
218
+ client.put("/v1/auth/accessor/revoke-accessor", JSON.fast_generate(
219
+ accessor: accessor,
220
+ ), headers)
204
221
  return true
205
222
  end
206
223
 
207
- # Revoke all auths in the tree.
224
+ # Revoke the token and all its children.
208
225
  #
209
226
  # @example
210
- # Vault.auth_token.revoke_tree("abcd-1234") #=> true
227
+ # Vault.auth_token.revoke("abcd-1234") #=> true
211
228
  #
212
- # @param [String] id
213
- # the auth id
229
+ # @param [String] token
230
+ # the auth token
214
231
  #
215
232
  # @return [true]
216
- def revoke_tree(id)
217
- client.put("/v1/auth/token/revoke/#{id}", nil)
233
+ def revoke(token, options = {})
234
+ headers = extract_headers!(options)
235
+ client.put("/v1/auth/token/revoke", JSON.fast_generate(
236
+ token: token,
237
+ ), headers)
218
238
  return true
219
239
  end
240
+ alias_method :revoke_tree, :revoke
220
241
  end
221
242
  end
@@ -7,6 +7,11 @@ module Vault
7
7
  # @return [Array<String>]
8
8
  field :keys
9
9
 
10
+ # @!attribute [r] keys_base64
11
+ # List of unseal keys, base64-encoded
12
+ # @return [Array<String>]
13
+ field :keys_base64
14
+
10
15
  # @!attribute [r] root_token
11
16
  # Initial root token.
12
17
  # @return [String]
@@ -40,19 +45,37 @@ module Vault
40
45
  # @param [Hash] options
41
46
  # the list of init options
42
47
  #
43
- # @option options [Fixnum] :shares
48
+ # @option options [String] :root_token_pgp_key
49
+ # optional base64-encoded PGP public key used to encrypt the initial root
50
+ # token.
51
+ # @option options [Fixnum] :secret_shares
44
52
  # the number of shares
45
- # @option options [Fixnum] :threshold
53
+ # @option options [Fixnum] :secret_threshold
46
54
  # the number of keys needed to unlock
47
- # @option options [Array] :pgp_keys
48
- # an optional Array of base64-encoded PGP public keys to encrypt shares with
55
+ # @option options [Array<String>] :pgp_keys
56
+ # an optional Array of base64-encoded PGP public keys to encrypt sharees
57
+ # @option options [Fixnum] :stored_shares
58
+ # the number of shares that should be encrypted by the HSM for
59
+ # auto-unsealing
60
+ # @option options [Fixnum] :recovery_shares
61
+ # the number of shares to split the recovery key into
62
+ # @option options [Fixnum] :recovery_threshold
63
+ # the number of shares required to reconstruct the recovery key
64
+ # @option options [Array<String>] :recovery_pgp_keys
65
+ # an array of PGP public keys used to encrypt the output for the recovery
66
+ # keys
49
67
  #
50
68
  # @return [InitResponse]
51
69
  def init(options = {})
52
70
  json = client.put("/v1/sys/init", JSON.fast_generate(
53
- secret_shares: options.fetch(:shares, 5),
54
- secret_threshold: options.fetch(:threshold, 3),
55
- pgp_keys: options.fetch(:pgp_keys, nil)
71
+ root_token_pgp_key: options.fetch(:root_token_pgp_key, nil),
72
+ secret_shares: options.fetch(:secret_shares, options.fetch(:shares, 5)),
73
+ secret_threshold: options.fetch(:secret_threshold, options.fetch(:threshold, 3)),
74
+ pgp_keys: options.fetch(:pgp_keys, nil),
75
+ stored_shares: options.fetch(:stored_shares, nil),
76
+ recovery_shares: options.fetch(:recovery_shares, nil),
77
+ recovery_threshold: options.fetch(:recovery_threshold, nil),
78
+ recovery_pgp_keys: options.fetch(:recovery_pgp_keys, nil),
56
79
  ))
57
80
  return InitResponse.decode(json)
58
81
  end
@@ -85,6 +85,10 @@ module Vault
85
85
 
86
86
  @nhp = PersistentHTTP.new(name: "vault-ruby")
87
87
 
88
+ if hostname
89
+ @nhp.hostname = hostname
90
+ end
91
+
88
92
  if proxy_address
89
93
  proxy_uri = URI.parse "http://#{proxy_address}"
90
94
 
@@ -6,6 +6,7 @@ module Vault
6
6
  @keys ||= [
7
7
  :address,
8
8
  :token,
9
+ :hostname,
9
10
  :open_timeout,
10
11
  :proxy_address,
11
12
  :proxy_password,
@@ -53,6 +53,12 @@ module Vault
53
53
  nil
54
54
  end
55
55
 
56
+ # The SNI host to use when connecting to Vault via TLS.
57
+ # @return [String, nil]
58
+ def hostname
59
+ ENV["VAULT_TLS_SERVER_NAME"]
60
+ end
61
+
56
62
  # The number of seconds to wait when trying to open a connection before
57
63
  # timing out
58
64
  # @return [String, nil]
@@ -642,7 +642,10 @@ class PersistentHTTP
642
642
 
643
643
  raise Error, "host down: #{address}:#{port}"
644
644
  ensure
645
- @pool.checkin net_http_args
645
+ # Only perform checkin if we successfully checked a connection out
646
+ if connection
647
+ @pool.checkin net_http_args
648
+ end
646
649
  end
647
650
 
648
651
  ##
@@ -74,7 +74,7 @@ module Vault
74
74
  h[k] = self.public_send(opts[:as])
75
75
  end
76
76
 
77
- if !h[k].nil? && h[k].respond_to?(:to_h)
77
+ if !h[k].nil? && !h[k].is_a?(Array) && h[k].respond_to?(:to_h)
78
78
  h[k] = h[k].to_h
79
79
  end
80
80
 
@@ -1,3 +1,3 @@
1
1
  module Vault
2
- VERSION = "0.7.3"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "pry"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.5"
26
26
  spec.add_development_dependency "yard"
27
- spec.add_development_dependency "webmock", "~> 1.22"
27
+ spec.add_development_dependency "webmock", "~> 2.3"
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.0'
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: '10.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.22'
89
+ version: '2.3'
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: '1.22'
96
+ version: '2.3'
97
97
  description: Vault is a Ruby API client for interacting with a Vault server.
98
98
  email:
99
99
  - sethvargo@gmail.com