Prometheus: Ensure auth config can be switched away from Azure option (#95003)

fix: sanitize jsondata when azure auth disabled
This commit is contained in:
Nick Richmond 2024-10-29 12:15:19 -04:00 committed by GitHub
parent 03715f062b
commit 6be787dd47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,9 +8,15 @@ import { Alert, SecureSocksProxySettings, useTheme2 } from '@grafana/ui';
// NEED TO EXPORT THIS FROM GRAFANA/UI FOR EXTERNAL DS
import { AzureAuthSettings } from '@grafana/ui/src/components/DataSourceSettings/types';
import type { AzureCredentials } from './AzureCredentials';
interface PromOptionsWithCloudAuth extends PromOptions {
azureCredentials?: AzureCredentials;
}
type Props = {
options: DataSourceSettings<PromOptions, {}>;
onOptionsChange: (options: DataSourceSettings<PromOptions, {}>) => void;
options: DataSourceSettings<PromOptionsWithCloudAuth, {}>;
onOptionsChange: (options: DataSourceSettings<PromOptionsWithCloudAuth, {}>) => void;
azureAuthSettings: AzureAuthSettings;
sigV4AuthToggleEnabled: boolean | undefined;
renderSigV4Editor: React.ReactNode;
@ -73,7 +79,7 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
const azureAuthOption: CustomMethod = {
id: azureAuthId,
label: 'Azure auth',
description: 'This is Azure auth description',
description: 'Authenticate with Azure',
component: (
<>
{azureAuthSettings.azureSettingsUI && (
@ -161,6 +167,7 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
withCredentials: method === AuthMethod.CrossSiteCredentials,
jsonData: {
...options.jsonData,
azureCredentials: method === azureAuthId ? options.jsonData.azureCredentials : undefined,
sigV4Auth: method === sigV4Id,
oauthPassThru: method === AuthMethod.OAuthForward,
},