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