kerberos save logic
This commit is contained in:
parent
70f1629be0
commit
1a78540c8f
4 changed files with 63 additions and 37 deletions
|
@ -37,6 +37,7 @@ const KerberosSettingsHeader = ({
|
|||
toggleDeleteDialog,
|
||||
}: KerberosSettingsHeaderProps) => {
|
||||
const { t } = useTranslation("user-federation");
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({
|
||||
titleKey: "user-federation:userFedDisableConfirmTitle",
|
||||
messageKey: "user-federation:userFedDisableConfirm",
|
||||
|
@ -49,6 +50,9 @@ const KerberosSettingsHeader = ({
|
|||
return (
|
||||
<>
|
||||
<DisableConfirm />
|
||||
{id === "new" ? (
|
||||
<ViewHeader titleKey="Kerberos" subKey="" />
|
||||
) : (
|
||||
<ViewHeader
|
||||
titleKey="Kerberos"
|
||||
subKey=""
|
||||
|
@ -67,6 +71,7 @@ const KerberosSettingsHeader = ({
|
|||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -92,8 +97,6 @@ export const UserFederationKerberosSettings = () => {
|
|||
}, []);
|
||||
|
||||
const setupForm = (component: ComponentRepresentation) => {
|
||||
console.log("READING as:");
|
||||
console.log(component);
|
||||
Object.entries(component).map((entry) => {
|
||||
form.setValue(
|
||||
"config.allowPasswordAuthentication",
|
||||
|
@ -107,18 +110,24 @@ export const UserFederationKerberosSettings = () => {
|
|||
};
|
||||
|
||||
const save = async (component: ComponentRepresentation) => {
|
||||
console.log("SAVING as:");
|
||||
console.log(component);
|
||||
try {
|
||||
if (id) {
|
||||
await adminClient.components.update({ id }, component);
|
||||
} else {
|
||||
if (id === "new") {
|
||||
await adminClient.components.create(component);
|
||||
} else {
|
||||
await adminClient.components.update({ id }, component);
|
||||
}
|
||||
}
|
||||
setupForm(component as ComponentRepresentation);
|
||||
addAlert(t("saveSuccess"), AlertVariant.success);
|
||||
addAlert(
|
||||
t(id === "new" ? "createSuccess" : "saveSuccess"),
|
||||
AlertVariant.success
|
||||
);
|
||||
} catch (error) {
|
||||
addAlert(`${t("saveError")} '${error}'`, AlertVariant.danger);
|
||||
addAlert(
|
||||
`${t(id === "new" ? "createError" : "saveError")} '${error}'`,
|
||||
AlertVariant.danger
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -143,7 +152,7 @@ export const UserFederationKerberosSettings = () => {
|
|||
<DeleteConfirm />
|
||||
<Controller
|
||||
name="config.enabled[0]"
|
||||
defaultValue={["true"]}
|
||||
defaultValue={["true"][0]}
|
||||
control={form.control}
|
||||
render={({ onChange, value }) => (
|
||||
<KerberosSettingsHeader
|
||||
|
|
|
@ -58,8 +58,18 @@ export const UserFederationSection = () => {
|
|||
}, [key]);
|
||||
|
||||
const ufAddProviderDropdownItems = [
|
||||
<DropdownItem key="itemLDAP" onClick={() => history.push(`${url}/ldap/new`)}>LDAP</DropdownItem>,
|
||||
<DropdownItem key="itemKerberos" onClick={() => history.push(`${url}/kerberos/new`)}>Kerberos</DropdownItem>,
|
||||
<DropdownItem
|
||||
key="itemLDAP"
|
||||
onClick={() => history.push(`${url}/ldap/new`)}
|
||||
>
|
||||
LDAP
|
||||
</DropdownItem>,
|
||||
<DropdownItem
|
||||
key="itemKerberos"
|
||||
onClick={() => history.push(`${url}/kerberos/new`)}
|
||||
>
|
||||
Kerberos
|
||||
</DropdownItem>,
|
||||
];
|
||||
|
||||
const learnMoreLinkProps = {
|
||||
|
|
|
@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
|
|||
import { UseFormMethods, Controller, useWatch } from "react-hook-form";
|
||||
|
||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||
|
||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||
import _ from "lodash";
|
||||
|
@ -29,6 +30,7 @@ export const KerberosSettingsRequired = ({
|
|||
}: KerberosSettingsRequiredProps) => {
|
||||
const { t } = useTranslation("user-federation");
|
||||
const helpText = useTranslation("user-federation-help").t;
|
||||
const { realm } = useRealm();
|
||||
|
||||
const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false);
|
||||
|
||||
|
@ -62,18 +64,19 @@ export const KerberosSettingsRequired = ({
|
|||
isRequired
|
||||
>
|
||||
{/* These hidden fields are required so data object written back matches data retrieved */}
|
||||
<TextInput
|
||||
{/* <TextInput
|
||||
hidden
|
||||
type="text"
|
||||
id="kc-console-id"
|
||||
name="id"
|
||||
ref={form.register}
|
||||
/>
|
||||
/> */}
|
||||
<TextInput
|
||||
hidden
|
||||
type="text"
|
||||
id="kc-console-providerId"
|
||||
name="providerId"
|
||||
defaultValue="kerberos"
|
||||
ref={form.register}
|
||||
/>
|
||||
<TextInput
|
||||
|
@ -81,6 +84,7 @@ export const KerberosSettingsRequired = ({
|
|||
type="text"
|
||||
id="kc-console-providerType"
|
||||
name="providerType"
|
||||
defaultValue="org.keycloak.storage.UserStorageProvider"
|
||||
ref={form.register}
|
||||
/>
|
||||
<TextInput
|
||||
|
@ -88,6 +92,7 @@ export const KerberosSettingsRequired = ({
|
|||
type="text"
|
||||
id="kc-console-parentId"
|
||||
name="parentId"
|
||||
defaultValue={realm}
|
||||
ref={form.register}
|
||||
/>
|
||||
|
||||
|
@ -222,7 +227,7 @@ export const KerberosSettingsRequired = ({
|
|||
{" "}
|
||||
<Controller
|
||||
name="config.debug"
|
||||
defaultValue={false}
|
||||
defaultValue={["false"]}
|
||||
control={form.control}
|
||||
render={({ onChange, value }) => (
|
||||
<Switch
|
||||
|
@ -251,7 +256,7 @@ export const KerberosSettingsRequired = ({
|
|||
>
|
||||
<Controller
|
||||
name="config.allowPasswordAuthentication"
|
||||
defaultValue={false}
|
||||
defaultValue={["false"]}
|
||||
control={form.control}
|
||||
render={({ onChange, value }) => (
|
||||
<Switch
|
||||
|
@ -324,7 +329,7 @@ export const KerberosSettingsRequired = ({
|
|||
>
|
||||
<Controller
|
||||
name="config.updateProfileFirstLogin"
|
||||
defaultValue={false}
|
||||
defaultValue={["false"]}
|
||||
control={form.control}
|
||||
render={({ onChange, value }) => (
|
||||
<Switch
|
||||
|
|
|
@ -80,8 +80,10 @@
|
|||
"oneLevel": "One Level",
|
||||
"subtree": "Subtree",
|
||||
|
||||
"saveSuccess": "User federation successfully saved",
|
||||
"saveError": "User federation could not be saved: {error}",
|
||||
"saveSuccess": "User federation provider successfully saved",
|
||||
"saveError": "User federation provider could not be saved: {error}",
|
||||
"createSuccess": "User federation provider successfully created",
|
||||
"createError": "User federation provider could not be created: {error}",
|
||||
|
||||
"learnMore": "Learn more",
|
||||
"addNewProvider": "Add new provider",
|
||||
|
|
Loading…
Reference in a new issue