Преглед изворни кода

Allow the use of auth and credentials in opentsdb

Pablo Fischer пре 10 година
родитељ
комит
98082a940c
1 измењених фајлова са 11 додато и 0 уклоњено
  1. 11 0
      public/app/plugins/datasource/opentsdb/datasource.js

+ 11 - 0
public/app/plugins/datasource/opentsdb/datasource.js

@@ -13,6 +13,8 @@ function (angular, _, dateMath) {
     this.type = 'opentsdb';
     this.type = 'opentsdb';
     this.url = instanceSettings.url;
     this.url = instanceSettings.url;
     this.name = instanceSettings.name;
     this.name = instanceSettings.name;
+    this.withCredentials = instanceSettings.withCredentials;
+    this.basicAuth = instanceSettings.basicAuth;
     this.supportMetrics = true;
     this.supportMetrics = true;
 
 
     // Called once per panel (graph)
     // Called once per panel (graph)
@@ -71,6 +73,15 @@ function (angular, _, dateMath) {
         url: this.url + '/api/query',
         url: this.url + '/api/query',
         data: reqBody
         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
       // In case the backend is 3rd-party hosted and does not suport OPTIONS, urlencoded requests
       // go as POST rather than OPTIONS+POST
       // go as POST rather than OPTIONS+POST