Chore: move sessionId from Live service (#64465)

* remove sessionid from live

* remove sessionid from live

* use uuid rather than math.random
This commit is contained in:
Artur Wierzbicki 2023-03-09 10:01:44 +04:00 committed by GitHub
parent 4b94c7e5d2
commit f23c8e5cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 14 deletions

View File

@ -1,5 +1,5 @@
// BETTERER RESULTS V2.
//
//
// If this file contains merge conflicts, use `betterer merge` to automatically resolve them:
// https://phenomnomnominal.github.io/betterer/docs/results-file/#merge
//
@ -3675,9 +3675,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/live/index.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/live/pages/AddNewRule.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]

View File

@ -29,7 +29,6 @@ export type CentrifugeSrvDeps = {
appUrl: string;
orgId: number;
orgRole: string;
sessionId: string;
liveEnabled: boolean;
dataStreamSubscriberReadiness: Observable<boolean>;
};

View File

@ -1,4 +1,5 @@
import { Unsubscribable } from 'rxjs';
import { v4 as uuidv4 } from 'uuid';
import {
AppEvents,
@ -11,7 +12,6 @@ import {
} from '@grafana/data';
import { getGrafanaLiveSrv, locationService } from '@grafana/runtime';
import { appEvents, contextSrv } from 'app/core/core';
import { sessionId } from 'app/features/live';
import { ShowModalReactEvent } from '../../../types/events';
import { getDashboardSrv } from '../../dashboard/services/DashboardSrv';
@ -19,6 +19,10 @@ import { getDashboardSrv } from '../../dashboard/services/DashboardSrv';
import { DashboardChangedModal } from './DashboardChangedModal';
import { DashboardEvent, DashboardEventAction } from './types';
// sessionId is not a security-sensitive value.
// It is used for filtering out dashboard edit events from the same browsing session
const sessionId = uuidv4();
class DashboardWatcher {
channel?: LiveChannelAddress; // path to the channel
uid?: string;

View File

@ -8,20 +8,12 @@ import { CentrifugeService } from './centrifuge/service';
import { CentrifugeServiceWorkerProxy } from './centrifuge/serviceWorkerProxy';
import { GrafanaLiveService } from './live';
export const sessionId =
(window as any)?.grafanaBootData?.user?.id +
'/' +
Date.now().toString(16) +
'/' +
Math.random().toString(36).substring(2, 15);
export function initGrafanaLive() {
const centrifugeServiceDeps = {
appUrl: `${window.location.origin}${config.appSubUrl}`,
orgId: contextSrv.user.orgId,
orgRole: contextSrv.user.orgRole,
liveEnabled: config.liveEnabled,
sessionId,
dataStreamSubscriberReadiness: liveTimer.ok.asObservable(),
grafanaAuthToken: loadUrlToken(),
};