mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 06:56:07 -06:00
Prometheus: Fix config bug for sigv4 auth (#76390)
fix config bug for selecting sigv4
This commit is contained in:
parent
9d8be05cce
commit
67e3e576d0
@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { DataSourceSettings } from '@grafana/data';
|
||||
import { Auth, ConnectionSettings, convertLegacyAuthProps } from '@grafana/experimental';
|
||||
import { Auth, ConnectionSettings, convertLegacyAuthProps, AuthMethod } from '@grafana/experimental';
|
||||
import { SecureSocksProxySettings, useTheme2 } from '@grafana/ui';
|
||||
import { AzureAuthSettings } from '@grafana/ui/src/components/DataSourceSettings/types';
|
||||
|
||||
@ -127,21 +127,12 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
|
||||
/>
|
||||
<hr className={`${styles.hrTopSpace} ${styles.hrBottomSpace}`} />
|
||||
<Auth
|
||||
// Reshaped legacy props
|
||||
{...newAuthProps}
|
||||
// Your custom auth methods
|
||||
customMethods={customMethods}
|
||||
// Still need to call `onAuthMethodSelect` function from
|
||||
// `newAuthProps` to store the legacy data correctly.
|
||||
// Also make sure to store the data about your component
|
||||
// being selected/unselected.
|
||||
onAuthMethodSelect={(method) => {
|
||||
// handle selecting of custom methods
|
||||
// sigV4Id
|
||||
if (sigV4AuthToggleEnabled) {
|
||||
setSigV4Selected(method === sigV4Id);
|
||||
// mutate jsonData here to store the selected option because of auth component issue with onOptionsChange being overridden
|
||||
options.jsonData.sigV4Auth = method === sigV4Id;
|
||||
}
|
||||
|
||||
// Azure
|
||||
@ -150,7 +141,16 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
|
||||
azureAuthSettings.setAzureAuthEnabled(options, method === azureAuthId);
|
||||
}
|
||||
|
||||
newAuthProps.onAuthMethodSelect(method);
|
||||
onOptionsChange({
|
||||
...options,
|
||||
basicAuth: method === AuthMethod.BasicAuth,
|
||||
withCredentials: method === AuthMethod.CrossSiteCredentials,
|
||||
jsonData: {
|
||||
...options.jsonData,
|
||||
sigV4Auth: method === sigV4Id,
|
||||
oauthPassThru: method === AuthMethod.OAuthForward,
|
||||
},
|
||||
});
|
||||
}}
|
||||
// If your method is selected pass its id to `selectedMethod`,
|
||||
// otherwise pass the id from converted legacy data
|
||||
|
@ -46,6 +46,7 @@ export interface PromOptions extends DataSourceJsonData {
|
||||
incrementalQueryOverlapWindow?: string;
|
||||
disableRecordingRules?: boolean;
|
||||
sigV4Auth?: boolean;
|
||||
oauthPassThru?: boolean;
|
||||
}
|
||||
|
||||
export type ExemplarTraceIdDestination = {
|
||||
|
Loading…
Reference in New Issue
Block a user