Skip to content

Commit

Permalink
feat: pass user id in req headers
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Dec 18, 2024
1 parent 70633f0 commit 5df7c2e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
VariableOption,
VariableWithMultiSupport,
} from '@grafana/data';
import { FetchResponse, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
import { config, FetchResponse, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
import { isArray, isObject } from 'lodash';
import { lastValueFrom } from 'rxjs';
import { map } from 'rxjs/operators';
Expand Down Expand Up @@ -50,7 +50,10 @@ export class DataSource extends DataSourceApi<GrafanaQuery, GenericOptions> {

this.variables = new VariableSupport(this, this.templateSrv);
this.withCredentials = instanceSettings.withCredentials !== undefined;
this.headers = { 'Content-Type': 'application/json' };
this.headers = {
'Content-Type': 'application/json',
'X-Grafana-User-Id': config.bootData.user.id,
};
if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) {
this.headers['Authorization'] = instanceSettings.basicAuth;
}
Expand Down

0 comments on commit 5df7c2e

Please sign in to comment.