From 1de4b10d9199c8be60e379a69d525441c5225fed Mon Sep 17 00:00:00 2001 From: rcoomans Date: Tue, 4 Nov 2014 17:02:00 +0100 Subject: [PATCH] fix for #335 --- .../dashboard/stream/ProxyStreamServlet.java | 8 ++++++-- hystrix-dashboard/src/main/webapp/index.html | 6 +++++- .../src/main/webapp/monitor/monitor.html | 13 +++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/ProxyStreamServlet.java b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/ProxyStreamServlet.java index 70e156526..1afd22bcd 100644 --- a/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/ProxyStreamServlet.java +++ b/hystrix-dashboard/src/main/java/com/netflix/hystrix/dashboard/stream/ProxyStreamServlet.java @@ -39,13 +39,14 @@ public ProxyStreamServlet() { */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String origin = request.getParameter("origin"); + String authorization = request.getParameter("authorization"); if (origin == null) { response.setStatus(500); response.getWriter().println("Required parameter 'origin' missing. Example: 107.20.175.135:7001"); return; } origin = origin.trim(); - + HttpGet httpget = null; InputStream is = null; boolean hasFirstParameter = false; @@ -60,7 +61,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t @SuppressWarnings("unchecked") Map params = request.getParameterMap(); for (String key : params.keySet()) { - if (!key.equals("origin")) { + if (!key.equals("origin") && !key.equals("authorization")) { String[] values = params.get(key); String value = values[0].trim(); if (hasFirstParameter) { @@ -76,6 +77,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t logger.info("\n\nProxy opening connection to: " + proxyUrl + "\n\n"); try { httpget = new HttpGet(proxyUrl); + if (authorization != null) { + httpget.addHeader("Authorization", authorization); + } HttpClient client = ProxyConnectionManager.httpClient; HttpResponse httpResponse = client.execute(httpget); int statusCode = httpResponse.getStatusLine().getStatusCode(); diff --git a/hystrix-dashboard/src/main/webapp/index.html b/hystrix-dashboard/src/main/webapp/index.html index 72b9fbc44..8a1531e73 100644 --- a/hystrix-dashboard/src/main/webapp/index.html +++ b/hystrix-dashboard/src/main/webapp/index.html @@ -18,6 +18,9 @@ if($('#title').val().length > 0) { url += "&title=" + encodeURIComponent($('#title').val()); } + if($('#authorization').val().length > 0) { + url += "&authorization=" + encodeURIComponent($('#authorization').val()); + } location.href= url; } else { $('#message').html("The 'stream' value is required."); @@ -44,7 +47,8 @@

Hystrix Dashboard



Delay: ms      - Title:
+ Title:

+ Authorization:



diff --git a/hystrix-dashboard/src/main/webapp/monitor/monitor.html b/hystrix-dashboard/src/main/webapp/monitor/monitor.html index 68c84f9a7..e766540f7 100644 --- a/hystrix-dashboard/src/main/webapp/monitor/monitor.html +++ b/hystrix-dashboard/src/main/webapp/monitor/monitor.html @@ -93,15 +93,20 @@

if(getUrlVars()["delay"] != undefined) { stream = stream + "&delay=" + getUrlVars()["delay"]; } - - var commandStream = "../proxy.stream?origin=" + stream; - var poolStream = "../proxy.stream?origin=" + stream; - + if(getUrlVars()["title"] != undefined) { $('#title_name').html("Hystrix Stream: " + decodeURIComponent(getUrlVars()["title"])) } else { $('#title_name').html("Hystrix Stream: " + decodeURIComponent(stream)) } + + //do not show authorization in stream title + if(getUrlVars()["authorization"] != undefined) { + stream = stream + "&authorization=" + getUrlVars()["authorization"]; + } + + var commandStream = "../proxy.stream?origin=" + stream; + var poolStream = "../proxy.stream?origin=" + stream; } $(window).load(function() { // within load with a setTimeout to prevent the infinite spinner