2020-11-25 16:17:50 +00:00
|
|
|
import { FormGroup, Switch } from "@patternfly/react-core";
|
2020-10-30 20:15:37 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2020-12-16 07:02:41 +00:00
|
|
|
import React, { useEffect } from "react";
|
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
2020-11-25 14:50:40 +00:00
|
|
|
import { useForm, Controller } from "react-hook-form";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { convertToFormValues } from "../../util";
|
2020-11-25 14:50:40 +00:00
|
|
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
2021-01-11 18:56:19 +00:00
|
|
|
import {
|
|
|
|
useAdminClient,
|
|
|
|
asyncStateFetch,
|
|
|
|
} from "../../context/auth/AdminClient";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { useParams } from "react-router-dom";
|
2020-10-30 20:15:37 +00:00
|
|
|
|
|
|
|
export const LdapSettingsAdvanced = () => {
|
|
|
|
const { t } = useTranslation("user-federation");
|
|
|
|
const helpText = useTranslation("user-federation-help").t;
|
2020-12-16 07:02:41 +00:00
|
|
|
const adminClient = useAdminClient();
|
|
|
|
const { control, setValue } = useForm<ComponentRepresentation>();
|
|
|
|
const { id } = useParams<{ id: string }>();
|
2020-10-30 20:15:37 +00:00
|
|
|
|
2020-12-16 07:02:41 +00:00
|
|
|
const setupForm = (component: ComponentRepresentation) => {
|
|
|
|
Object.entries(component).map((entry) => {
|
|
|
|
if (entry[0] === "config") {
|
|
|
|
convertToFormValues(entry[1], "config", setValue);
|
|
|
|
} else {
|
|
|
|
setValue(entry[0], entry[1]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-01-11 18:56:19 +00:00
|
|
|
return asyncStateFetch(
|
2021-01-05 13:39:27 +00:00
|
|
|
() => adminClient.components.findOne({ id }),
|
|
|
|
(fetchedComponent) => setupForm(fetchedComponent)
|
|
|
|
);
|
2020-12-16 07:02:41 +00:00
|
|
|
}, []);
|
2020-11-25 14:50:40 +00:00
|
|
|
|
2020-10-30 20:15:37 +00:00
|
|
|
return (
|
|
|
|
<>
|
2020-11-25 16:17:50 +00:00
|
|
|
<FormAccess role="manage-realm" isHorizontal>
|
2020-10-30 20:15:37 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("enableLdapv3Password")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("enableLdapv3PasswordHelp")}
|
|
|
|
forLabel={t("enableLdapv3Password")}
|
|
|
|
forID="kc-enable-ldapv3-password"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-enable-ldapv3-password"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2020-12-16 07:02:41 +00:00
|
|
|
name="config.usePasswordModifyExtendedOp"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id={"kc-enable-ldapv3-password"}
|
2020-12-16 07:02:41 +00:00
|
|
|
isChecked={value[0] === "true"}
|
2020-11-25 14:50:40 +00:00
|
|
|
isDisabled={false}
|
|
|
|
onChange={onChange}
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup
|
|
|
|
label={t("validatePasswordPolicy")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("validatePasswordPolicyHelp")}
|
|
|
|
forLabel={t("validatePasswordPolicy")}
|
|
|
|
forID="kc-validate-password-policy"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-validate-password-policy"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2020-12-16 07:02:41 +00:00
|
|
|
name="config.validatePasswordPolicy"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id={"kc-validate-password-policy"}
|
2020-12-16 07:02:41 +00:00
|
|
|
isChecked={value[0] === "true"}
|
2020-11-25 14:50:40 +00:00
|
|
|
isDisabled={false}
|
|
|
|
onChange={onChange}
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup
|
|
|
|
label={t("trustEmail")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("trustEmailHelp")}
|
|
|
|
forLabel={t("trustEmail")}
|
|
|
|
forID="kc-trust-email"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-trust-email"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2020-12-16 07:02:41 +00:00
|
|
|
name="config.trustEmail"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue={false}
|
|
|
|
control={control}
|
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id={"kc-trust-email"}
|
2020-12-16 07:02:41 +00:00
|
|
|
isChecked={value[0] === "true"}
|
2020-11-25 14:50:40 +00:00
|
|
|
isDisabled={false}
|
|
|
|
onChange={onChange}
|
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
2020-11-25 16:17:50 +00:00
|
|
|
</FormAccess>
|
2020-10-30 20:15:37 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|