rack-proxy 0.5.6 → 0.5.8

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: 01ead5716a3297d180ef585021e3ef8f9061be22
4
- data.tar.gz: 9492773b1b285a2265b4f5767d93b381a05f4e4c
3
+ metadata.gz: 053b64c1db8f801c328770098e15672e2b17da53
4
+ data.tar.gz: 7b114c1eecafdc79dab20c75a0daf073b87496be
5
5
  SHA512:
6
- metadata.gz: 62b54b36a5276cf2cb8a16793ced71283d2fb597fc3aab91fd867c6e8f29f80e2193a3f2371afed2007a7b3866db156620599db7e9eb54d3756153588651ec1a
7
- data.tar.gz: a895ec06fee93eb01265e47a053066859f4bf6bea21dfbf70aacb6443b5c59d6d377afecbabbc5f13680b4b867ccef08be00112f98430fa2177fae887d1a73b6
6
+ metadata.gz: cd49785b803394666dea8e1bd14d0afedb2da3b2d7f72ea6b57167d2cdc83cbf66e9864ce7c3d9314e7a00157531b11bb70e41cb4dc9341332317c6baf091750
7
+ data.tar.gz: a30031d0598443126fcf82213dee26fd20443b4cd7f547080950d9a8f88b31dd712a245d0a9ef720e51ad54e885ba928449d08816179531b16ce0af093aae663
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-proxy (0.5.5)
4
+ rack-proxy (0.5.8)
5
5
  rack
6
6
 
7
7
  GEM
data/Readme CHANGED
@@ -22,6 +22,22 @@ class Foo < Rack::Proxy
22
22
 
23
23
  end
24
24
 
25
+ Example: disable SSL session verification when proxying a server with e.g. self-signed SSL certs
26
+
27
+ class TrustingProxy < Rack::Proxy
28
+
29
+ def rewrite_env(env)
30
+ env["rack.ssl_verify_none"] = true
31
+
32
+ env
33
+ end
34
+
35
+ end
36
+
37
+ The same can be achieved for *all* requests going through the `Rack::Proxy` instance by using
38
+
39
+ Rack::Proxy.new(ssl_verify_none: true)
40
+
25
41
  See tests for more examples.
26
42
 
27
43
  WARNING: Doesn't work with fakeweb/webmock. Both libraries monkey-patch net/http code.
@@ -5,6 +5,7 @@ module Rack
5
5
  # Wraps the hacked net/http in a Rack way.
6
6
  class HttpStreamingResponse
7
7
  attr_accessor :use_ssl
8
+ attr_accessor :verify_mode
8
9
 
9
10
  def initialize(request, host, port = nil)
10
11
  @request, @host, @port = request, host, port
@@ -61,6 +62,7 @@ module Rack
61
62
  @session ||= begin
62
63
  http = Net::HTTP.new @host, @port
63
64
  http.use_ssl = self.use_ssl
65
+ http.verify_mode = self.verify_mode
64
66
  http.start
65
67
  end
66
68
  end
data/lib/rack/proxy.rb CHANGED
@@ -5,11 +5,12 @@ module Rack
5
5
 
6
6
  # Subclass and bring your own #rewrite_request and #rewrite_response
7
7
  class Proxy
8
- VERSION = "0.5.6"
8
+ VERSION = "0.5.8"
9
9
 
10
10
  # @option opts [String, URI::HTTP] :backend Backend host to proxy requests to
11
11
  def initialize(opts={})
12
12
  @streaming = opts.fetch(:streaming, true)
13
+ @ssl_verify_none = opts.fetch(:ssl_verify_none, false)
13
14
  @backend = URI(opts[:backend]) if opts[:backend]
14
15
  end
15
16
 
@@ -57,14 +58,17 @@ module Rack
57
58
 
58
59
  backend = @backend || source_request
59
60
  use_ssl = backend.scheme == "https"
61
+ ssl_verify_none = (env.delete('rack.ssl_verify_none') || @ssl_verify_none) == true
60
62
 
61
63
  # Create the response
62
64
  if @streaming
63
65
  # streaming response (the actual network communication is deferred, a.k.a. streamed)
64
66
  target_response = HttpStreamingResponse.new(target_request, backend.host, backend.port)
65
67
  target_response.use_ssl = use_ssl
68
+ target_response.verify_mode = OpenSSL::SSL::VERIFY_NONE if use_ssl && ssl_verify_none
66
69
  else
67
70
  target_response = Net::HTTP.start(backend.host, backend.port, :use_ssl => use_ssl) do |http|
71
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if use_ssl && ssl_verify_none
68
72
  http.request(target_request)
69
73
  end
70
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacek Becela
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack