LDAP: Render bind password as a secret input field (#94376)

render bind password as a secret input field
This commit is contained in:
Mihai Doarna 2024-10-08 12:54:16 +03:00 committed by GitHub
parent 6190499f03
commit 501f1bc7a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,6 +20,7 @@ import {
TextLink,
Dropdown,
MultiSelect,
SecretInput,
} from '@grafana/ui';
import { FormPrompt } from 'app/core/components/FormPrompt/FormPrompt';
import { Page } from 'app/core/components/Page/Page';
@ -98,6 +99,7 @@ export const LdapSettingsPage = () => {
const [isLoading, setIsLoading] = useState(true);
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const [isBindPasswordConfigured, setBindPasswordConfigured] = useState(false);
const [mapKeyCertConfigured, setMapKeyCertConfigured] = useState<MapKeyCertConfigured>({
// values
rootCaCertValue: false,
@ -114,6 +116,7 @@ export const LdapSettingsPage = () => {
control,
formState: { isDirty },
getValues,
setValue,
handleSubmit,
register,
reset,
@ -137,6 +140,7 @@ export const LdapSettingsPage = () => {
clientCertPath: isOptionDefined(serverConfig.client_cert),
clientKeyCertPath: isOptionDefined(serverConfig.client_key),
});
setBindPasswordConfigured(isOptionDefined(serverConfig.bind_password));
reset(payload);
setIsLoading(false);
@ -325,10 +329,15 @@ export const LdapSettingsPage = () => {
/>
</Field>
<Field label={t('ldap-settings-page.bind-password.label', 'Bind password')}>
<Input
<SecretInput
id="bind-password"
type="text"
{...register(`${serverConfig}.bind_password`, { required: false })}
isConfigured={isBindPasswordConfigured}
onReset={() => {
setValue(`${serverConfig}.bind_password`, '');
setBindPasswordConfigured(false);
}}
value={watch(`${serverConfig}.bind_password`)}
onChange={({ currentTarget: { value } }) => setValue(`${serverConfig}.bind_password`, value)}
/>
</Field>
<Field