lib/conjur/webserver/server.rb in conjur-asset-ui-1.3.1 vs lib/conjur/webserver/server.rb in conjur-asset-ui-1.3.2

- old
+ new

@@ -29,16 +29,10 @@ require 'conjur/webserver/authorize' require 'conjur/webserver/api_proxy' require 'conjur/webserver/home' require 'conjur/webserver/conjur_info' - # Pry is optional - begin - require 'pry' - rescue LoadError - end - sessionid = self.sessionid cookie_options = { secret: SecureRandom.hex(32), expire_after: 24*60*60 } @@ -56,11 +50,11 @@ end map "/api" do api_stack.each{|args| use *args} run Conjur::WebServer::APIProxy.new end - %w(build js css fonts images).each do |path| + %w(js css fonts images).each do |path| map "/#{path}" do run Rack::File.new(File.join(root, path), 'Cache-Control' => 'max-age=0') end end map "/ui" do @@ -81,35 +75,35 @@ # instead we just explicitly set RACK_ENV to "production" on the command call -- this is also bad, but... good enough for now, until we'll fix API configuration logic Conjur.configuration.env Rack::Server.start(options) end - + def open require 'launchy' url = "http://localhost:#{port}/login?sessionid=#{sessionid}" # as launchy sometimes silently fails, we need human-friendly failover - $stderr.puts "If your browser did not opened the UI automatically, point it to #{url}" - Launchy.open(url) unless ENV['DONT_OPEN_IN_BROWSER'] + $stderr.puts "If your browser did not opened the UI automatically, point it to #{url}" + Launchy.open(url) end - + protected - + def port @port ||= find_available_port end DEFAULT_PORT = 42_289 - + def find_available_port begin server = TCPServer.new('127.0.0.1', 0) server.addr[1] ensure server.close if server end end - + def sessionid require 'securerandom' @sessionid ||= SecureRandom.hex(32) end end