From bb64e812d81553c422f51c9af8d58f05a65e829f Mon Sep 17 00:00:00 2001 From: Theral Mackey Date: Tue, 25 Feb 2014 16:06:44 -0800 Subject: [PATCH] Bugfix for Basic Auth: strip auth from url before using This fixes the Basic Auth not working issue (issue#16) further, by removing the auth string from the URL before grafana attempts to use it. Some js doesn't handle it properly and tries to include the auth string in dns lookups(?), so the request never even hits the graphite server when an auth string is present. --- src/app/services/graphite/graphiteDatasource.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 2f735412dd2..c137b79990e 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -14,7 +14,15 @@ function (angular, _, $, config, kbn, moment) { module.factory('GraphiteDatasource', function(dashboard, $q, filterSrv, $http) { function GraphiteDatasource(datasource) { - this.url = datasource.url; + var passwordEnd = datasource.url.indexOf('@'); + if(passwordEnd > 0) { + var userStart = datasource.url.indexOf('//') + 2; + var urlHead = datasource.url.substring(0,userStart); + this.url = urlHead + datasource.url.substring(passwordEnd); + } + else { + this.url = datasource.url; + } this.type = 'graphite'; this.basicAuth = datasource.basicAuth; }