LDAP: Render root CA and client cert as text fields (#94382)

render root CA and client cert as text fields
This commit is contained in:
Mihai Doarna 2024-10-08 18:54:34 +03:00 committed by GitHub
parent 546d1517fa
commit 4bbae5eb0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 36 deletions

View File

@ -369,17 +369,14 @@ export const LdapDrawerComponent = ({
<Field
label={t('ldap-drawer.extra-security-section.client-cert-value-label', 'Client certificate content')}
>
<SecretInput
<Input
id="client-cert"
placeholder={t(
'ldap-drawer.extra-security-section.client-cert-value-placeholder',
'Client certificate content in base64'
)}
isConfigured={mapCertConfigured.clientCertValue}
onReset={() => {
setValue(`${serverConfig}.client_cert_value`, '');
setMapCertConfigured({ ...mapCertConfigured, clientCertValue: false });
}}
type="text"
{...register(`${serverConfig}.client_cert_value`)}
/>
</Field>
<Field label={t('ldap-drawer.extra-security-section.client-key-value-label', 'Client key content')}>
@ -401,35 +398,25 @@ export const LdapDrawerComponent = ({
{encryptionProvider === EncryptionProvider.FilePath && (
<>
<Field label={t('ldap-drawer.extra-security-section.root-ca-cert-label', 'Root CA certificate path')}>
<SecretInput
<Input
id="root-ca-cert"
placeholder={t(
'ldap-drawer.extra-security-section.root-ca-cert-placeholder',
'/path/to/root_ca_cert.pem'
)}
isConfigured={mapCertConfigured.rootCaCertPath}
onReset={() => {
setValue(`${serverConfig}.root_ca_cert`, '');
setMapCertConfigured({ ...mapCertConfigured, rootCaCertPath: false });
}}
value={watch(`${serverConfig}.root_ca_cert`)}
onChange={({ currentTarget: { value } }) => setValue(`${serverConfig}.root_ca_cert`, value)}
type="text"
{...register(`${serverConfig}.root_ca_cert`)}
/>
</Field>
<Field label={t('ldap-drawer.extra-security-section.client-cert-label', 'Client certificate path')}>
<SecretInput
<Input
id="client-cert"
placeholder={t(
'ldap-drawer.extra-security-section.client-cert-placeholder',
'/path/to/client_cert.pem'
)}
isConfigured={mapCertConfigured.clientCertPath}
onReset={() => {
setValue(`${serverConfig}.client_cert`, '');
setMapCertConfigured({ ...mapCertConfigured, clientCertPath: false });
}}
value={watch(`${serverConfig}.client_cert`)}
onChange={({ currentTarget: { value } }) => setValue(`${serverConfig}.client_cert`, value)}
type="text"
{...register(`${serverConfig}.client_cert`)}
/>
</Field>
<Field label={t('ldap-drawer.extra-security-section.client-key-label', 'Client key path')}>

View File

@ -101,13 +101,7 @@ export const LdapSettingsPage = () => {
const [isBindPasswordConfigured, setBindPasswordConfigured] = useState(false);
const [mapKeyCertConfigured, setMapKeyCertConfigured] = useState<MapKeyCertConfigured>({
// values
rootCaCertValue: false,
clientCertValue: false,
clientKeyCertValue: false,
// paths
rootCaCertPath: false,
clientCertPath: false,
clientKeyCertPath: false,
});
@ -133,11 +127,7 @@ export const LdapSettingsPage = () => {
serverConfig = payload.settings.config.servers[0];
}
setMapKeyCertConfigured({
rootCaCertValue: serverConfig.root_ca_cert_value?.length > 0,
clientCertValue: isOptionDefined(serverConfig.client_cert_value),
clientKeyCertValue: isOptionDefined(serverConfig.client_key_value),
rootCaCertPath: isOptionDefined(serverConfig.root_ca_cert),
clientCertPath: isOptionDefined(serverConfig.client_cert),
clientKeyCertPath: isOptionDefined(serverConfig.client_key),
});
setBindPasswordConfigured(isOptionDefined(serverConfig.bind_password));

View File

@ -140,10 +140,6 @@ export interface LdapPayload {
}
export interface MapKeyCertConfigured {
rootCaCertValue: boolean;
clientCertValue: boolean;
clientKeyCertValue: boolean;
rootCaCertPath: boolean;
clientCertPath: boolean;
clientKeyCertPath: boolean;
}