Class: Conjur::Proxy
- Inherits:
-
Object
- Object
- Conjur::Proxy
- Defined in:
- lib/conjur/proxy.rb
Instance Attribute Summary collapse
-
#conjur ⇒ Object
readonly
Returns the value of attribute conjur.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(url, conjur) ⇒ Proxy
constructor
A new instance of Proxy.
- #start(options) ⇒ Object
Constructor Details
#initialize(url, conjur) ⇒ Proxy
Returns a new instance of Proxy.
27 28 29 30 31 32 |
# File 'lib/conjur/proxy.rb', line 27 def initialize url, conjur @conjur = conjur @proxy = Rack::StreamingProxy::Proxy.new nil do |request| url + request.path end end |
Instance Attribute Details
#conjur ⇒ Object (readonly)
Returns the value of attribute conjur.
34 35 36 |
# File 'lib/conjur/proxy.rb', line 34 def conjur @conjur end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
34 35 36 |
# File 'lib/conjur/proxy.rb', line 34 def proxy @proxy end |
Instance Method Details
#call(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/conjur/proxy.rb', line 36 def call env env["HTTP_AUTHORIZATION"] = conjur.credentials[:headers][:authorization] ret = proxy.call env # hack for Docker Hub & Registry API if ret[1].include?('x-docker-endpoints') ret[1]['x-docker-endpoints'] = env['HTTP_HOST'] end ret end |
#start(options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/conjur/proxy.rb', line 49 def start if [:insecure] Net::HTTP.class_eval do def use_ssl=(flag) flag = flag ? true : false if started? and @use_ssl != flag raise IOError, "use_ssl value changed, but session already started" end @use_ssl = flag self.verify_mode = OpenSSL::SSL::VERIFY_NONE end end end if [:cacert] OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file [:cacert] end Rack::Server.start app: self, Port: [:port] || 8080, Host: [:address] || '127.0.0.1' end |