keycloak-scim/js/apps/admin-ui/src/clients/add/SamlConfig.tsx

79 lines
2.2 KiB
TypeScript
Raw Normal View History

import { Path, PathValue } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { SelectControl } from "ui-shared";
import { DefaultSwitchControl } from "../../components/SwitchControl";
import { FormAccess } from "../../components/form/FormAccess";
import { convertAttributeNameToForm } from "../../util";
import { FormFields } from "../ClientDetails";
2021-10-05 10:32:20 +00:00
type ToggleProps = {
name: PathValue<FormFields, Path<FormFields>>;
label: string;
};
export const Toggle = ({ name, label }: ToggleProps) => {
const { t } = useTranslation();
2021-10-05 10:32:20 +00:00
return (
<DefaultSwitchControl
name={name}
2021-10-05 10:32:20 +00:00
label={t(label)}
labelIcon={t(`${label}Help`)}
stringify
/>
2021-10-05 10:32:20 +00:00
);
};
export const SamlConfig = () => {
const { t } = useTranslation();
2021-10-05 10:32:20 +00:00
return (
<FormAccess
isHorizontal
role="manage-clients"
className="keycloak__capability-config__form"
>
<SelectControl
name="attributes.saml_name_id_format"
2021-10-05 10:32:20 +00:00
label={t("nameIdFormat")}
labelIcon={t("nameIdFormatHelp")}
controller={{
defaultValue: "username",
}}
options={["username", "email", "transient", "persistent"]}
/>
2021-10-05 10:32:20 +00:00
<Toggle
name="attributes.saml_force_name_id_format"
2021-10-05 10:32:20 +00:00
label="forceNameIdFormat"
/>
<Toggle
name={convertAttributeNameToForm("attributes.saml.force.post.binding")}
2021-10-05 10:32:20 +00:00
label="forcePostBinding"
/>
<Toggle
name={convertAttributeNameToForm("attributes.saml.artifact.binding")}
2021-10-05 10:32:20 +00:00
label="forceArtifactBinding"
/>
2022-03-02 21:38:52 +00:00
<Toggle
name={convertAttributeNameToForm("attributes.saml.authnstatement")}
2022-03-02 21:38:52 +00:00
label="includeAuthnStatement"
/>
2021-10-05 10:32:20 +00:00
<Toggle
name={convertAttributeNameToForm(
"attributes.saml.onetimeuse.condition",
)}
2021-10-05 10:32:20 +00:00
label="includeOneTimeUseCondition"
/>
<Toggle
name={convertAttributeNameToForm(
"attributes.saml.server.signature.keyinfo.ext",
)}
2021-10-05 10:32:20 +00:00
label="optimizeLookup"
/>
<Toggle
name={convertAttributeNameToForm("attributes.saml.allow.ecp.flow")}
label="allowEcpFlow"
/>
2021-10-05 10:32:20 +00:00
</FormAccess>
);
};