class Conjur::Proxy
Attributes
conjur[R]
proxy[R]
Public Class Methods
new(url, conjur)
click to toggle source
# File lib/conjur/proxy.rb, line 28 def initialize url, conjur @conjur = conjur @proxy = Rack::StreamingProxy::Proxy.new nil do |request| ret = "#{url}#{request.path}" unless request.query_string.empty? ret = "#{ret}?#{request.query_string}" end ret end end
Public Instance Methods
call(env)
click to toggle source
# File lib/conjur/proxy.rb, line 43 def call env env['HTTP_AUTHORIZATION'] = conjur.credentials[:headers][:authorization] if (env['REQUEST_METHOD'] == 'POST' || env['REQUEST_METHOD'] == 'PUT') if !env.include?('CONTENT_LENGTH') && (!env.include?('TRANSFER_ENCODING') || env['TRANSFER_ENCODING'] != 'chunked') env['CONTENT_LENGTH'] = '0' end end 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
configure(options = {})
click to toggle source
# File lib/conjur/proxy.rb, line 63 def configure options = {} if options[: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 options[:cacert] OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file options[:cacert] end Rack::StreamingProxy::Session.class_eval do # set timeout to 30 min, 30 seconds is not enought for uploading def start @piper = Servolux::Piper.new 'r', timeout: 1600 @piper.child { child } @piper.parent { parent } end end end
start()
click to toggle source
set timeout to 30 min, 30 seconds is not enought for uploading
# File lib/conjur/proxy.rb, line 84 def start @piper = Servolux::Piper.new 'r', timeout: 1600 @piper.child { child } @piper.parent { parent } end
use_ssl=(flag)
click to toggle source
# File lib/conjur/proxy.rb, line 66 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