mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Strip out auth token from shared URL when sharing a dashboard (#79262)
This commit is contained in:
@@ -29,6 +29,7 @@ describe('buildParams', () => {
|
||||
${'var=%2B1&var=a+value+with+spaces&var=true'} | ${false} | ${'current'} | ${{ id: 3 }} | ${'var=%2B1&var=a+value+with+spaces&var=true&orgId=2&viewPanel=3'}
|
||||
${'var=%2B1&var=a+value+with+spaces&var=true'} | ${false} | ${'light'} | ${undefined} | ${'var=%2B1&var=a+value+with+spaces&var=true&orgId=2&theme=light'}
|
||||
${'var=%2B1&var=a+value+with+spaces&var=true'} | ${false} | ${'light'} | ${{ id: 3 }} | ${'var=%2B1&var=a+value+with+spaces&var=true&orgId=2&theme=light&viewPanel=3'}
|
||||
${'auth_token=1234'} | ${true} | ${'current'} | ${undefined} | ${'from=1000&to=2000&orgId=2'}
|
||||
`(
|
||||
"when called with search: '$search' and useCurrentTimeRange: '$useCurrentTimeRange' and selectedTheme: '$selectedTheme' and panel: '$panel'then result should be '$expected'",
|
||||
({ search, useCurrentTimeRange, selectedTheme, panel, expected }) => {
|
||||
|
||||
@@ -49,6 +49,9 @@ export function buildParams({
|
||||
searchParams.set('viewPanel', String(panel.id));
|
||||
}
|
||||
|
||||
// Token is unique to the authenticated identity and should not be shared with the URL,
|
||||
// so we are stripping it from the query params as a safety measure.
|
||||
searchParams.delete('auth_token');
|
||||
return searchParams;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user