import { SyntheticEvent } from 'react'; import { DataSourcePluginOptionsEditorProps, updateDatasourcePluginJsonDataOption } from '@grafana/data'; import { ConfigSubSection } from '@grafana/experimental'; import { FieldSet, Input, Field } from '@grafana/ui'; import { MSSQLAuthenticationType, MssqlOptions } from '../types'; export const UsernameMessage = ( Use the format user@EXAMPLE.COM. Realm is derived from the username. ); export const KerberosConfig = (props: DataSourcePluginOptionsEditorProps) => { const { options: settings, onOptionsChange } = props; const jsonData = settings.jsonData; const LONG_WIDTH = 40; const keytabFilePath = jsonData?.keytabFilePath; const credentialCache = jsonData?.credentialCache; const credentialCacheLookupFile = jsonData?.credentialCacheLookupFile; const onKeytabFileChanged = (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, 'keytabFilePath', event.currentTarget.value); }; const onCredentialCacheChanged = (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, 'credentialCache', event.currentTarget.value); }; const onCredentialCacheFileChanged = (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, 'credentialCacheLookupFile', event.currentTarget.value); }; return ( <> {jsonData.authenticationType === MSSQLAuthenticationType.kerberosKeytab && (
onOptionsChange({ ...settings, ...{ ['user']: e.currentTarget.value } })} width={LONG_WIDTH} />
)} {jsonData.authenticationType === MSSQLAuthenticationType.kerberosCredentialCache && (
)} {jsonData.authenticationType === MSSQLAuthenticationType.kerberosCredentialCacheLookupFile && (
onOptionsChange({ ...settings, ...{ ['user']: e.currentTarget.value } })} width={LONG_WIDTH} />
)} ); }; export const KerberosAdvancedSettings = (props: DataSourcePluginOptionsEditorProps) => { const { options: settings } = props; const jsonData = settings.jsonData; const configFilePath = jsonData?.configFilePath; const LONG_WIDTH = 40; const onUDPLimitChanged = (val: number) => { updateDatasourcePluginJsonDataOption(props, 'UDPConnectionLimit', val); }; const onDNSLookupKDCChanged = (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, 'enableDNSLookupKDC', event.currentTarget.value); }; const onKrbConfigChanged = (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, 'configFilePath', event.currentTarget.value); }; return ( <>
The default is 1 and means always use TCP and is optional. } > { const val = Number(e.currentTarget.value); if (!Number.isNaN(val)) { onUDPLimitChanged(val); } }} /> Indicate whether DNS `SRV` records should be used to locate the KDCs and other servers for a realm. The default is true. } > The path to the configuration file for the{' '} MIT krb5 package . The default is /etc/krb5.conf. } >
); };