added dynamic components to client authenticator (#34259)

fixes: #33729

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-10-23 20:39:11 +02:00 committed by GitHub
parent 617d677341
commit e520c71a1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,17 +16,20 @@ import {
CardBody, CardBody,
ClipboardCopy, ClipboardCopy,
Divider, Divider,
Form,
FormGroup, FormGroup,
PageSection, PageSection,
Split, Split,
SplitItem, SplitItem,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { useState } from "react"; import { useMemo, useState } from "react";
import { useFormContext, useWatch } from "react-hook-form"; import { useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAdminClient } from "../../admin-client"; import { useAdminClient } from "../../admin-client";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
import { FormAccess } from "../../components/form/FormAccess"; import { FormAccess } from "../../components/form/FormAccess";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { FormFields } from "../ClientDetails"; import { FormFields } from "../ClientDetails";
import { ClientSecret } from "./ClientSecret"; import { ClientSecret } from "./ClientSecret";
import { SignedJWT } from "./SignedJWT"; import { SignedJWT } from "./SignedJWT";
@ -72,6 +75,15 @@ export const Credentials = ({ client, save, refresh }: CredentialsProps) => {
(provider) => provider.id === clientAuthenticatorType, (provider) => provider.id === clientAuthenticatorType,
); );
const { componentTypes } = useServerInfo();
const providerProperties = useMemo(
() =>
componentTypes?.["org.keycloak.authentication.ClientAuthenticator"]?.find(
(p) => p.id === clientAuthenticatorType,
)?.properties,
[clientAuthenticatorType, componentTypes],
);
useFetch( useFetch(
() => () =>
Promise.all([ Promise.all([
@ -170,6 +182,11 @@ export const Credentials = ({ client, save, refresh }: CredentialsProps) => {
</FormGroup> </FormGroup>
)} )}
{clientAuthenticatorType === "client-x509" && <X509 />} {clientAuthenticatorType === "client-x509" && <X509 />}
{providerProperties && (
<Form>
<DynamicComponents properties={providerProperties} />
</Form>
)}
<ActionGroup> <ActionGroup>
<Button variant="primary" type="submit" isDisabled={!isDirty}> <Button variant="primary" type="submit" isDisabled={!isDirty}>
{t("save")} {t("save")}