Mask private key when exporting SAML client (#1326)

This commit is contained in:
Jon Koops 2021-10-14 09:52:36 +02:00 committed by GitHub
parent d22095fc03
commit 01e6bfeef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -17,6 +17,7 @@ export default {
encryptAssertions: "Encrypt assertions", encryptAssertions: "Encrypt assertions",
clientSignature: "Client signature required", clientSignature: "Client signature required",
downloadAdaptorTitle: "Download adaptor configs", downloadAdaptorTitle: "Download adaptor configs",
privateKeyMask: "PRIVATE KEY NOT SET UP OR KNOWN",
keys: "Keys", keys: "Keys",
credentials: "Credentials", credentials: "Credentials",
roles: "Roles", roles: "Roles",

View file

@ -51,6 +51,12 @@ export const DownloadDialog = ({
[selected] [selected]
); );
const sanitizeSnippet = (snippet: string) =>
snippet.replace(
/(?<=<PrivateKeyPem>).*(?=<\/PrivateKeyPem>)/gs,
t("clients:privateKeyMask")
);
useFetch( useFetch(
async () => { async () => {
const snippet = await adminClient.clients.getInstallationProviders({ const snippet = await adminClient.clients.getInstallationProviders({
@ -58,7 +64,7 @@ export const DownloadDialog = ({
providerId: selected, providerId: selected,
}); });
if (typeof snippet === "string") { if (typeof snippet === "string") {
return snippet; return sanitizeSnippet(snippet);
} else { } else {
return prettyPrintJSON(snippet); return prettyPrintJSON(snippet);
} }