datasource-proxy: token exchange

This commit is contained in:
Torkel Ödegaard
2017-08-23 17:18:43 +02:00
parent 4f9fbcc211
commit 3c9798bec9
6 changed files with 130 additions and 33 deletions

View File

@@ -8,12 +8,20 @@ System.register([], function (_export) {
function Datasource(instanceSettings, backendSrv) {
this.url = instanceSettings.url;
// this.testDatasource = function() {
// return backendSrv.datasourceRequest({
// method: 'GET',
// url: this.url + '/api/v4/search'
// });
// }
//
this.testDatasource = function() {
return backendSrv.datasourceRequest({
method: 'GET',
url: this.url + '/api/v4/search'
url: this.url + '/tokenTest'
});
}
}
function ConfigCtrl() {
@@ -22,12 +30,16 @@ System.register([], function (_export) {
ConfigCtrl.template = `
<div class="gf-form">
<label class="gf-form-label width-13">Email </label>
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.email'></input>
<label class="gf-form-label width-13">TenantId </label>
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.tenantId'></input>
</div>
<div class="gf-form">
<label class="gf-form-label width-13">Access key ID </label>
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.secureJsonData.token'></input>
<label class="gf-form-label width-13">ClientId </label>
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.clientId'></input>
</div>
<div class="gf-form">
<label class="gf-form-label width-13">Client secret</label>
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.secureJsonData.clientSecret'></input>
</div>
`;

View File

@@ -5,12 +5,12 @@
"routes": [
{
"path": "api/v5/",
"path": "tokenTest",
"method": "*",
"url": "https://grafana-api.kentik.com/api/v5",
"url": "http://localhost:3333/query",
"tokenAuth": {
"url": "https://login.microsoftonline.com/{{.JsonData.tenantId}}/oauth2/token",
"body": {
"url": "https://login.microsoftonline.com/{{.JsonData.tenantId}}/oauth2/token",
"params": {
"grant_type": "client_credentials",
"client_id": "{{.JsonData.clientId}}",
"client_secret": "{{.SecureJsonData.clientSecret}}",