Merge pull request #440 from mfrances17/issue-399

Add missing kerberos-related fields to LDAP settings
This commit is contained in:
mfrances17 2021-03-15 14:10:56 -04:00 committed by GitHub
commit b9931fdc56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,8 @@
import { FormGroup, Switch } from "@patternfly/react-core";
import { FormGroup, Switch, TextInput } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import React from "react";
import { HelpItem } from "../../components/help-enabler/HelpItem";
import { UseFormMethods, Controller } from "react-hook-form";
import { UseFormMethods, Controller, useWatch } from "react-hook-form";
import { FormAccess } from "../../components/form-access/FormAccess";
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
@ -20,6 +20,12 @@ export const LdapSettingsKerberosIntegration = ({
const { t } = useTranslation("user-federation");
const helpText = useTranslation("user-federation-help").t;
const allowKerberosAuth: [string] = useWatch({
control: form.control,
name: "config.allowKerberosAuthentication",
defaultValue: ["true"],
});
return (
<>
{showSectionHeading && (
@ -59,6 +65,143 @@ export const LdapSettingsKerberosIntegration = ({
)}
></Controller>
</FormGroup>
{allowKerberosAuth[0] === "true" && (
<>
<FormGroup
label={t("kerberosRealm")}
labelIcon={
<HelpItem
helpText={helpText("kerberosRealmHelp")}
forLabel={t("kerberosRealm")}
forID="kc-kerberos-realm"
/>
}
fieldId="kc-kerberos-realm"
isRequired
>
<TextInput
isRequired
type="text"
id="kc-kerberos-realm"
name="config.kerberosRealm[0]"
ref={form.register({
required: {
value: true,
message: `${t("validateRealm")}`,
},
})}
data-testid="kerberos-realm"
/>
{form.errors.config &&
form.errors.config.kerberosRealm &&
form.errors.config.kerberosRealm[0] && (
<div className="error">
{form.errors.config.kerberosRealm[0].message}
</div>
)}
</FormGroup>
<FormGroup
label={t("serverPrincipal")}
labelIcon={
<HelpItem
helpText={helpText("serverPrincipalHelp")}
forLabel={t("serverPrincipal")}
forID="kc-server-principal"
/>
}
fieldId="kc-server-principal"
isRequired
>
<TextInput
isRequired
type="text"
id="kc-server-principal"
name="config.serverPrincipal[0]"
ref={form.register({
required: {
value: true,
message: `${t("validateServerPrincipal")}`,
},
})}
data-testid="kerberos-principal"
/>
{form.errors.config &&
form.errors.config.serverPrincipal &&
form.errors.config.serverPrincipal[0] && (
<div className="error">
{form.errors.config.serverPrincipal[0].message}
</div>
)}
</FormGroup>
<FormGroup
label={t("keyTab")}
labelIcon={
<HelpItem
helpText={helpText("keyTabHelp")}
forLabel={t("keyTab")}
forID="kc-key-tab"
/>
}
fieldId="kc-key-tab"
isRequired
>
<TextInput
isRequired
type="text"
id="kc-key-tab"
name="config.keyTab[0]"
ref={form.register({
required: {
value: true,
message: `${t("validateKeyTab")}`,
},
})}
data-testid="kerberos-keytab"
/>
{form.errors.config &&
form.errors.config.keyTab &&
form.errors.config.keyTab[0] && (
<div className="error">
{form.errors.config.keyTab[0].message}
</div>
)}
</FormGroup>
</>
)}
<FormGroup
label={t("debug")}
labelIcon={
<HelpItem
helpText={helpText("debugHelp")}
forLabel={t("debug")}
forID="kc-debug"
/>
}
fieldId="kc-debug"
hasNoPaddingTop
>
{" "}
<Controller
name="config.debug"
defaultValue={["false"]}
control={form.control}
render={({ onChange, value }) => (
<Switch
id={"kc-debug"}
isDisabled={false}
onChange={(value) => onChange([`${value}`])}
isChecked={value[0] === "true"}
label={t("common:on")}
labelOff={t("common:off")}
/>
)}
></Controller>
</FormGroup>
<FormGroup
label={t("useKerberosForPasswordAuthentication")}
labelIcon={