vault 0.2.0 → 0.3.0

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: 85725acc286dd2dc1e346442a4e528d7e11ae42e
4
- data.tar.gz: 6344245bd60e54203151708b45134c9ae2201a51
3
+ metadata.gz: f44b1c7408f1606c17e1b1aea67b3547aae80873
4
+ data.tar.gz: f908452ae3a2117b1b12c5305921f59242ef89ce
5
5
  SHA512:
6
- metadata.gz: 6d573f396ec086b8103a3d29750c92aa79c0dd0567c5eb511c60a2d9912ad9fb47ef7d4a7a43b910e480ba3742e61e24cd2df9b3fe30e215dfa8d5d22993da88
7
- data.tar.gz: 558a0c41ef94a57da06b5bb40bdd34fb07d0367a0ccdf7b51edae9d53fbb28940a81abccd5b9eccd78474493424d7f259459fcc8c522da515f3af37a0e8d5b2d
6
+ metadata.gz: 00352ca38411b6340b145dfad3bbe8c1f6d49535fbf169717ee60c37198e07e229e56b1f4b1e30fe907d5d542cfe7656ad3386570e2d2894d922935416ce6b0e
7
+ data.tar.gz: 5a4d53a45ee70b529d03e77fa3e73adabd2e538c3b18aa4547a1d0f78f733cea6337940b70105952b9067df7b9e5d40327bdef45b6b6b5b933eead0e59a46381
data/.gitignore CHANGED
@@ -30,9 +30,9 @@ build/
30
30
 
31
31
  # for a library or gem, you might want to ignore these files since the code is
32
32
  # intended to run in multiple environments; otherwise, check them in:
33
- # Gemfile.lock
34
- # .ruby-version
35
- # .ruby-gemset
33
+ Gemfile.lock
34
+ .ruby-version
35
+ .ruby-gemset
36
36
 
37
37
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
38
38
  .rvmrc
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ cache: bundler
3
3
  sudo: false
4
4
 
5
5
  before_install: |-
6
- wget -O vault.zip -q https://dl.bintray.com/mitchellh/vault/vault_0.2.0_linux_amd64.zip
6
+ wget -O vault.zip -q https://releases.hashicorp.com/vault/0.5.0-rc1/vault_0.5.0-rc1_linux_amd64.zip
7
7
  unzip vault.zip
8
8
  mkdir ~/bin
9
9
  mv vault ~/bin
@@ -18,3 +18,4 @@ rvm:
18
18
  - 2.0
19
19
  - 2.1
20
20
  - 2.2
21
+ - 2.3.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Vault Ruby Changelog
2
2
 
3
+ ## v0.3.0.dev (Unreleased)
4
+
5
+
6
+
7
+ ## v0.3.0 (February 16, 2016)
8
+
9
+ NEW FEATURES
10
+
11
+ - Add API for `renew_self`
12
+ - Add API for `revoke_self`
13
+ - Add API for listing secrets where supported
14
+
15
+ BUG FIXES
16
+
17
+ - Relax bundler constraint
18
+ - Fix race conditions on Ruby 2.3
19
+ - Escape path params before posting to Vault
20
+
3
21
  ## v0.2.0 (December 2, 2015)
4
22
 
5
23
  IMPROVEMENTS
data/lib/vault.rb CHANGED
@@ -31,8 +31,8 @@ module Vault
31
31
  # Delegate all methods to the client object, essentially making the module
32
32
  # object behave like a {Client}.
33
33
  def method_missing(m, *args, &block)
34
- if client.respond_to?(m)
35
- client.send(m, *args, &block)
34
+ if @client.respond_to?(m)
35
+ @client.send(m, *args, &block)
36
36
  else
37
37
  super
38
38
  end
@@ -40,7 +40,7 @@ module Vault
40
40
 
41
41
  # Delegating +respond_to+ to the {Client}.
42
42
  def respond_to_missing?(m, include_private = false)
43
- client.respond_to?(m, include_private) || super
43
+ @client.respond_to?(m, include_private) || super
44
44
  end
45
45
  end
46
46
  end
@@ -93,7 +93,7 @@ module Vault
93
93
  # @return [Secret]
94
94
  def userpass(username, password, options = {})
95
95
  payload = { password: password }.merge(options)
96
- json = client.post("/v1/auth/userpass/login/#{username}", JSON.fast_generate(payload))
96
+ json = client.post("/v1/auth/userpass/login/#{CGI.escape(username)}", JSON.fast_generate(payload))
97
97
  secret = Secret.decode(json)
98
98
  client.token = secret.auth.client_token
99
99
  return secret
@@ -45,6 +45,31 @@ module Vault
45
45
  return Secret.decode(json)
46
46
  end
47
47
 
48
+ # Renews a lease associated with the callign token.
49
+ #
50
+ # @example
51
+ # Vault.auth_token.renew_self #=> #<Vault::Secret lease_id="">
52
+ #
53
+ # @param [Fixnum] increment
54
+ #
55
+ # @return [Secret]
56
+ def renew_self(increment = 0)
57
+ json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
58
+ increment: increment,
59
+ ))
60
+ return Secret.decode(json)
61
+ end
62
+
63
+ # Revokes the token used to call it.
64
+ #
65
+ # @example
66
+ # Vault.auth_token.revoke_self #=> 204
67
+ #
68
+ # @return response code.
69
+ def revoke_self
70
+ client.post("/v1/auth/token/revoke-self")
71
+ end
72
+
48
73
  # Revoke exactly the orphans at the id.
49
74
  #
50
75
  # @example
@@ -16,7 +16,7 @@ module Vault
16
16
  #
17
17
  # @return [Help]
18
18
  def help(path)
19
- json = self.get("/v1/#{path}", help: 1)
19
+ json = self.get("/v1/#{CGI.escape(path)}", help: 1)
20
20
  return Help.decode(json)
21
21
  end
22
22
  end
@@ -13,6 +13,24 @@ module Vault
13
13
  end
14
14
 
15
15
  class Logical < Request
16
+ # List the secrets at the given path, if the path supports listing. If the
17
+ # the path does not exist, an exception will be raised.
18
+ #
19
+ # @example
20
+ # Vault.logical.list("secret") #=> [#<Vault::Secret>, #<Vault::Secret>, ...]
21
+ #
22
+ # @param [String] path
23
+ # the path to list
24
+ #
25
+ # @return [Array<String>]
26
+ def list(path)
27
+ json = client.get("/v1/#{CGI.escape(path)}", list: true)
28
+ json[:data][:keys] || []
29
+ rescue HTTPError => e
30
+ return [] if e.code == 404
31
+ raise
32
+ end
33
+
16
34
  # Read the secret at the given path. If the secret does not exist, +nil+
17
35
  # will be returned.
18
36
  #
@@ -24,7 +42,7 @@ module Vault
24
42
  #
25
43
  # @return [Secret, nil]
26
44
  def read(path)
27
- json = client.get("/v1/#{path}")
45
+ json = client.get("/v1/#{CGI.escape(path)}")
28
46
  return Secret.decode(json)
29
47
  rescue HTTPError => e
30
48
  return nil if e.code == 404
@@ -44,7 +62,7 @@ module Vault
44
62
  #
45
63
  # @return [Secret]
46
64
  def write(path, data = {})
47
- json = client.put("/v1/#{path}", JSON.fast_generate(data))
65
+ json = client.put("/v1/#{CGI.escape(path)}", JSON.fast_generate(data))
48
66
  if json.nil?
49
67
  return true
50
68
  else
@@ -63,7 +81,7 @@ module Vault
63
81
  #
64
82
  # @return [true]
65
83
  def delete(path)
66
- client.delete("/v1/#{path}")
84
+ client.delete("/v1/#{CGI.escape(path)}")
67
85
  return true
68
86
  end
69
87
  end
@@ -37,7 +37,7 @@ module Vault
37
37
  #
38
38
  # @return [true]
39
39
  def enable_audit(path, type, description, options = {})
40
- client.put("/v1/sys/audit/#{path}", JSON.fast_generate(
40
+ client.put("/v1/sys/audit/#{CGI.escape(path)}", JSON.fast_generate(
41
41
  type: type,
42
42
  description: description,
43
43
  options: options,
@@ -53,7 +53,7 @@ module Vault
53
53
  #
54
54
  # @return [true]
55
55
  def disable_audit(path)
56
- client.delete("/v1/sys/audit/#{path}")
56
+ client.delete("/v1/sys/audit/#{CGI.escape(path)}")
57
57
  return true
58
58
  end
59
59
  end
@@ -36,7 +36,7 @@ module Vault
36
36
  payload = { type: type }
37
37
  payload[:description] = description if !description.nil?
38
38
 
39
- client.post("/v1/sys/auth/#{path}", JSON.fast_generate(payload))
39
+ client.post("/v1/sys/auth/#{CGI.escape(path)}", JSON.fast_generate(payload))
40
40
  return true
41
41
  end
42
42
 
@@ -51,7 +51,7 @@ module Vault
51
51
  #
52
52
  # @return [true]
53
53
  def disable_auth(path)
54
- client.delete("/v1/sys/auth/#{path}")
54
+ client.delete("/v1/sys/auth/#{CGI.escape(path)}")
55
55
  return true
56
56
  end
57
57
  end
@@ -34,7 +34,7 @@ module Vault
34
34
  payload = { type: type }
35
35
  payload[:description] = description if !description.nil?
36
36
 
37
- client.post("/v1/sys/mounts/#{path}", JSON.fast_generate(payload))
37
+ client.post("/v1/sys/mounts/#{CGI.escape(path)}", JSON.fast_generate(payload))
38
38
  return true
39
39
  end
40
40
 
@@ -49,7 +49,7 @@ module Vault
49
49
  #
50
50
  # @return [true]
51
51
  def unmount(path)
52
- client.delete("/v1/sys/mounts/#{path}")
52
+ client.delete("/v1/sys/mounts/#{CGI.escape(path)}")
53
53
  return true
54
54
  end
55
55
 
@@ -24,7 +24,7 @@ module Vault
24
24
  #
25
25
  # @return [Policy, nil]
26
26
  def policy(name)
27
- json = client.get("/v1/sys/policy/#{name}")
27
+ json = client.get("/v1/sys/policy/#{CGI.escape(name)}")
28
28
  return Policy.decode(json)
29
29
  rescue HTTPError => e
30
30
  return nil if e.code == 404
@@ -54,7 +54,7 @@ module Vault
54
54
  #
55
55
  # @return [true]
56
56
  def put_policy(name, rules)
57
- client.put("/v1/sys/policy/#{name}", JSON.fast_generate(
57
+ client.put("/v1/sys/policy/#{CGI.escape(name)}", JSON.fast_generate(
58
58
  rules: rules,
59
59
  ))
60
60
  return true
@@ -69,7 +69,7 @@ module Vault
69
69
  # @param [String] name
70
70
  # the name of the policy
71
71
  def delete_policy(name)
72
- client.delete("/v1/sys/policy/#{name}")
72
+ client.delete("/v1/sys/policy/#{CGI.escape(name)}")
73
73
  return true
74
74
  end
75
75
  end
data/lib/vault/client.rb CHANGED
@@ -80,7 +80,7 @@ module Vault
80
80
 
81
81
  # Perform a POST request.
82
82
  # @see Client#request
83
- def post(path, data, headers = {})
83
+ def post(path, data = {}, headers = {})
84
84
  request(:post, path, data, headers)
85
85
  end
86
86
 
data/lib/vault/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vault
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/vault.gemspec CHANGED
@@ -19,7 +19,7 @@ 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_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "pry"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.2"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.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: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '0'
20
20
  type: :development
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: '1.9'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +92,6 @@ files:
92
92
  - ".travis.yml"
93
93
  - CHANGELOG.md
94
94
  - Gemfile
95
- - Gemfile.lock
96
95
  - LICENSE
97
96
  - README.md
98
97
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- vault (0.2.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- addressable (2.3.8)
10
- coderay (1.1.0)
11
- crack (0.4.2)
12
- safe_yaml (~> 1.0.0)
13
- diff-lcs (1.2.5)
14
- hashdiff (0.2.3)
15
- method_source (0.8.2)
16
- pry (0.10.1)
17
- coderay (~> 1.1.0)
18
- method_source (~> 0.8.1)
19
- slop (~> 3.4)
20
- rake (10.4.2)
21
- rspec (3.2.0)
22
- rspec-core (~> 3.2.0)
23
- rspec-expectations (~> 3.2.0)
24
- rspec-mocks (~> 3.2.0)
25
- rspec-core (3.2.3)
26
- rspec-support (~> 3.2.0)
27
- rspec-expectations (3.2.1)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.2.0)
30
- rspec-mocks (3.2.1)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.2.0)
33
- rspec-support (3.2.2)
34
- safe_yaml (1.0.4)
35
- slop (3.6.0)
36
- webmock (1.22.3)
37
- addressable (>= 2.3.6)
38
- crack (>= 0.3.2)
39
- hashdiff
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- bundler (~> 1.9)
46
- pry
47
- rake (~> 10.0)
48
- rspec (~> 3.2)
49
- vault!
50
- webmock (~> 1.22)
51
-
52
- BUNDLED WITH
53
- 1.10.6