use realm id instead of realm name (#1051)

fixes: #1042
This commit is contained in:
Erik Jan de Wit 2021-08-24 12:39:16 +02:00 committed by GitHub
parent 4d789f84e3
commit 4fc3865bbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View file

@ -40,9 +40,10 @@ export const UserFederationSection = () => {
const history = useHistory(); const history = useHistory();
useFetch( useFetch(
() => { async () => {
const realmModel = await adminClient.realms.findOne({ realm });
const testParams: { [name: string]: string | number } = { const testParams: { [name: string]: string | number } = {
parentId: realm, parentId: realmModel.id!,
type: "org.keycloak.storage.UserStorageProvider", type: "org.keycloak.storage.UserStorageProvider",
}; };
return adminClient.components.find(testParams); return adminClient.components.find(testParams);

View file

@ -16,6 +16,7 @@ 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";
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
export type KerberosSettingsRequiredProps = { export type KerberosSettingsRequiredProps = {
form: UseFormMethods; form: UseFormMethods;
@ -30,6 +31,8 @@ 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 adminClient = useAdminClient();
const { realm } = useRealm(); const { realm } = useRealm();
const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false); const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false);
@ -39,6 +42,12 @@ export const KerberosSettingsRequired = ({
name: "config.allowPasswordAuthentication", name: "config.allowPasswordAuthentication",
}); });
useFetch(
() => adminClient.realms.findOne({ realm }),
(result) => form.setValue("parentId", result.id),
[]
);
return ( return (
<> <>
{showSectionHeading && ( {showSectionHeading && (

View file

@ -13,6 +13,7 @@ import { FormAccess } from "../../components/form-access/FormAccess";
import { useRealm } from "../../context/realm-context/RealmContext"; import { useRealm } from "../../context/realm-context/RealmContext";
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
export type LdapSettingsGeneralProps = { export type LdapSettingsGeneralProps = {
form: UseFormMethods; form: UseFormMethods;
@ -27,8 +28,15 @@ export const LdapSettingsGeneral = ({
}: LdapSettingsGeneralProps) => { }: LdapSettingsGeneralProps) => {
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 adminClient = useAdminClient();
const { realm } = useRealm(); const { realm } = useRealm();
useFetch(
() => adminClient.realms.findOne({ realm }),
(result) => form.setValue("parentId", result.id),
[]
);
const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false); const [isVendorDropdownOpen, setIsVendorDropdownOpen] = useState(false);
const setVendorDefaultValues = () => { const setVendorDefaultValues = () => {