From 98082a940cb9ce4345fd1e6b9e96a2a26670dd26 Mon Sep 17 00:00:00 2001 From: Pablo Fischer Date: Sat, 30 Jan 2016 01:09:55 +0000 Subject: [PATCH 1/2] Allow the use of auth and credentials in opentsdb --- public/app/plugins/datasource/opentsdb/datasource.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index f4680038e8d..733cf25b737 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -13,6 +13,8 @@ function (angular, _, dateMath) { this.type = 'opentsdb'; this.url = instanceSettings.url; this.name = instanceSettings.name; + this.withCredentials = instanceSettings.withCredentials; + this.basicAuth = instanceSettings.basicAuth; this.supportMetrics = true; // Called once per panel (graph) @@ -71,6 +73,15 @@ function (angular, _, dateMath) { url: this.url + '/api/query', data: reqBody }; + + if (this.basicAuth || this.withCredentials) { + options.withCredentials = true; + } + if (this.basicAuth) { + options.headers = { + "Authorization": this.basicAuth + }; + } // In case the backend is 3rd-party hosted and does not suport OPTIONS, urlencoded requests // go as POST rather than OPTIONS+POST From f33de8e911ab726f975808bf25d6b6c21d75a441 Mon Sep 17 00:00:00 2001 From: Pablo Fischer Date: Mon, 1 Feb 2016 09:29:57 +0000 Subject: [PATCH 2/2] Fix lint/syntax (grunt test) --- public/app/plugins/datasource/opentsdb/datasource.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 733cf25b737..c8d40e35dcb 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -73,7 +73,6 @@ function (angular, _, dateMath) { url: this.url + '/api/query', data: reqBody }; - if (this.basicAuth || this.withCredentials) { options.withCredentials = true; }