vault 0.1.4 → 0.1.5

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: 4e65904a28c46a6472dbbf09106bf0a195f9d291
4
- data.tar.gz: 6ffa1d55b773e146db6292da052a8a05aa6e6ba4
3
+ metadata.gz: 8070f5204dc7fb565bfd50f5ba081fcd43b871ee
4
+ data.tar.gz: ee1b072bdf2cf41a886b35fcb765337bdb18b260
5
5
  SHA512:
6
- metadata.gz: ea8558f0ffc17e853c0042555add482dfbc4c43a8061df636dd8441602d5e2610ffe2c7c241074108eb6c8aae84ecd9e3175417fc636e5071a9f978771d292f4
7
- data.tar.gz: d87e2b3784fc0c9ee8d701d8fbbebaa5ddd319ba907452bf4e44ecf0eb1137d32e48adaed433a93dff38fcbb427d2c7d43be4f958d220d679c4b8e128a670cef
6
+ metadata.gz: a4ef3702182f75b6d33b48be4d93f3bb8c0ea66920bc9b63cbaa46be9983a934c2611728fef80260d591293d87b941a07904d5add95f65feebd9847efc8125d0
7
+ data.tar.gz: dbb8386139effe9ba92a6803e7f20074a0a1ae92fe527d113113f9d6f95495465ac4ab190e13ae6ff944ffc09f480ff251904cf1e9edaa274bb715a3908746ca
@@ -1,5 +1,16 @@
1
1
  # Vault Ruby Changelog
2
2
 
3
+ ## v0.1.5 (September 1, 2015)
4
+
5
+ IMPROVEMENTS
6
+
7
+ - Use headers instead of cookies for authenticating to Vault [GH-36]
8
+
9
+ BUG FIXES
10
+
11
+ - Do not set undefined OpenSSL options
12
+ - Add `ssl_pem_passphrase` as a configuration option [GH-35]
13
+
3
14
  ## v0.1.4 (August 15, 2015)
4
15
 
5
16
  IMPROVEMENTS
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vault (0.1.4)
4
+ vault (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -18,10 +18,12 @@ module Vault
18
18
  @client = Vault::Client.new
19
19
 
20
20
  # Set secure SSL options
21
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
22
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_COMPRESSION
23
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv2
24
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv3
21
+ OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options].tap do |opts|
22
+ opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
23
+ opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
24
+ opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
25
+ opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
26
+ end
25
27
 
26
28
  self
27
29
  end
@@ -1,5 +1,4 @@
1
1
  require "cgi"
2
- require "cgi/cookie"
3
2
  require "json"
4
3
  require "net/http"
5
4
  require "net/https"
@@ -14,6 +13,9 @@ module Vault
14
13
  # The user agent for this client.
15
14
  USER_AGENT = "VaultRuby/#{Vault::VERSION} (+github.com/hashicorp/vault-ruby)".freeze
16
15
 
16
+ # The name of the header used to hold the Vault token.
17
+ TOKEN_HEADER = "X-Vault-Token".freeze
18
+
17
19
  # The default headers that are sent with every request.
18
20
  DEFAULT_HEADERS = {
19
21
  "Content-Type" => "application/json",
@@ -121,8 +123,16 @@ module Vault
121
123
  uri = build_uri(verb, path, data)
122
124
  request = class_for_request(verb).new(uri.request_uri)
123
125
 
124
- # Add headers
126
+ # Get a list of headers
125
127
  headers = DEFAULT_HEADERS.merge(headers)
128
+
129
+ # Add the Vault token header - users could still override this on a
130
+ # per-request basis
131
+ if !token.nil?
132
+ request.add_field(TOKEN_HEADER, token)
133
+ end
134
+
135
+ # Add headers
126
136
  headers.each do |key, value|
127
137
  request.add_field(key, value)
128
138
  end
@@ -155,13 +165,6 @@ module Vault
155
165
  connection.read_timeout = (read_timeout || timeout).to_i
156
166
  end
157
167
 
158
- # Create the cookie for the request.
159
- cookie = CGI::Cookie.new
160
- cookie.name = "token"
161
- cookie.value = token
162
- cookie.path = "/"
163
- cookie.expires = Time.now + (60*60*24*365)
164
-
165
168
  # Apply SSL, if applicable
166
169
  if uri.scheme == "https"
167
170
  # Turn on SSL
@@ -173,9 +176,6 @@ module Vault
173
176
  # Only use secure ciphers
174
177
  connection.ciphers = ssl_ciphers
175
178
 
176
- # Turn on secure cookies
177
- cookie.secure = true
178
-
179
179
  # Custom pem files, no problem!
180
180
  if ssl_pem_file
181
181
  pem = File.read(ssl_pem_file)
@@ -206,11 +206,6 @@ module Vault
206
206
  end
207
207
  end
208
208
 
209
- # Add the cookie to the request if a token was given.
210
- if !token.nil?
211
- request["Cookie"] = cookie.to_s
212
- end
213
-
214
209
  begin
215
210
  # Create a connection using the block form, which will ensure the socket
216
211
  # is properly closed in the event of an error.
@@ -14,6 +14,7 @@ module Vault
14
14
  :read_timeout,
15
15
  :ssl_ciphers,
16
16
  :ssl_pem_file,
17
+ :ssl_pem_passphrase,
17
18
  :ssl_ca_cert,
18
19
  :ssl_ca_path,
19
20
  :ssl_verify,
@@ -89,7 +89,7 @@ module Vault
89
89
  ENV["VAULT_SSL_CERT"]
90
90
  end
91
91
 
92
- # The path to a pem on disk to use with custom SSL verification
92
+ # Passphrase to the pem file on disk to use with custom SSL verification
93
93
  # @return [String, nil]
94
94
  def ssl_pem_passphrase
95
95
  ENV["VAULT_SSL_CERT_PASSPHRASE"]
@@ -1,3 +1,3 @@
1
1
  module Vault
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  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.1.4
4
+ version: 0.1.5
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-08-15 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler