From 66a448720ad2d90a6b8710f14d251fa769abd62d Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 27 Oct 2022 13:40:51 +0200 Subject: [PATCH] Added PEM format for SAML (#3649) --- .../src/clients/keys/GenerateKeyDialog.tsx | 32 +++++++++++++------ .../src/clients/keys/SamlImportKeyDialog.tsx | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx b/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx index 72e65cf947..1853e33e6b 100644 --- a/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx +++ b/apps/admin-ui/src/clients/keys/GenerateKeyDialog.tsx @@ -34,15 +34,23 @@ type GenerateKeyDialogProps = { type KeyFormProps = { useFile?: boolean; isSaml?: boolean; + hasPem?: boolean; }; -export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { +const CERT_PEM = "Certificate PEM" as const; + +export const KeyForm = ({ + isSaml = false, + hasPem = false, + useFile = false, +}: KeyFormProps) => { const { t } = useTranslation("clients"); const [filename, setFilename] = useState(); const [openArchiveFormat, setOpenArchiveFormat] = useState(false); - const { control } = useFormContext(); + const { control, watch } = useFormContext(); + const format = watch("format"); return (
@@ -73,13 +81,15 @@ export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { aria-label={t("archiveFormat")} isOpen={openArchiveFormat} > - {["JKS", "PKCS12"].map((option) => ( - - ))} + {["JKS", "PKCS12"] + .concat(hasPem ? CERT_PEM : []) + .map((option) => ( + + ))} )} /> @@ -114,7 +124,9 @@ export const KeyForm = ({ isSaml = false, useFile = false }: KeyFormProps) => { /> )} - + {format !== CERT_PEM && ( + + )} ); }; diff --git a/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx b/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx index e514d064de..250ab5badf 100644 --- a/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx +++ b/apps/admin-ui/src/clients/keys/SamlImportKeyDialog.tsx @@ -49,7 +49,7 @@ export const SamlImportKeyDialog = ({ }} > - + );