Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

avoid duplicate tags

Thiago Araujo da Silvad9f6c9908b07
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
index f178c5ac38..2d2e0f1525 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
@@ -51,7 +51,7 @@ import { OIDCJWTSignatureAlgorithm } from "@app/hooks/api/oidcConfig/types";
import { SsoMfaTrust } from "@app/hooks/api/organization/types";
import { UsePopUpState } from "@app/hooks/usePopUp";
-import { FormSection } from "./SsoFormSection";
+import { FormSection, rejectDuplicateTag } from "./SsoFormSection";
enum ConfigurationType {
CUSTOM = "custom",
@@ -144,6 +144,7 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
const { mutateAsync: updateMutateAsync, isPending: updateIsLoading } = useUpdateOIDCConfig();
const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle(false);
const [isClientSecretRevealed, setIsClientSecretRevealed] = useState(false);
+ const [amrValueTagError, setAmrValueTagError] = useState<string | null>(null);
const { data } = useGetOIDCConfig(currentOrg?.id ?? "");
@@ -517,12 +518,14 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
placeholder="Type a value, press Enter"
value={value ?? []}
onValueChange={onChange}
- isError={Boolean(error)}
+ validateTag={rejectDuplicateTag}
+ onValidationError={setAmrValueTagError}
+ isError={Boolean(amrValueTagError || error)}
/>
<FieldDescription>
Counted as MFA in addition to the standard <Code>mfa</Code> value.
</FieldDescription>
- <FieldError>{error?.message}</FieldError>
+ <FieldError>{amrValueTagError ?? error?.message}</FieldError>
</Field>
)}
/>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
index 389e8a7bed..3a67162046 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
@@ -1,4 +1,4 @@
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { Trash2 } from "lucide-react";
@@ -43,7 +43,7 @@ import { useCreateSSOConfig, useGetSSOConfig, useUpdateSSOConfig } from "@app/ho
import { SsoMfaTrust } from "@app/hooks/api/organization/types";
import { UsePopUpState } from "@app/hooks/usePopUp";
-import { FormSection } from "./SsoFormSection";
+import { FormSection, rejectDuplicateTag } from "./SsoFormSection";
enum AuthProvider {
OKTA_SAML = "okta-saml",
@@ -197,6 +197,7 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
const { mutateAsync: createMutateAsync, isPending: createIsLoading } = useCreateSSOConfig();
const { mutateAsync: updateMutateAsync, isPending: updateIsLoading } = useUpdateSSOConfig();
const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle();
+ const [authnContextTagError, setAuthnContextTagError] = useState<string | null>(null);
const { data } = useGetSSOConfig(currentOrg?.id ?? "");
const { control, handleSubmit, reset, watch, setValue, getValues } = useForm<AddSSOFormData>({
@@ -350,7 +351,10 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
label={withHint(labels.acsUrl, labels.acsHint)}
value={`${window.origin}/api/v1/sso/saml2/${data.id}`}
/>
- <CodeBlock label={withHint(labels.entityId, labels.entityHint)} value={window.origin} />
+ <CodeBlock
+ label={withHint(labels.entityId, labels.entityHint)}
+ value={window.origin}
+ />
</FormSection>
)}
@@ -458,13 +462,15 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
placeholder="urn:oasis:names:tc:SAML:2.0:ac:classes:..."
value={value}
onValueChange={onChange}
- isError={Boolean(error)}
+ validateTag={rejectDuplicateTag}
+ onValidationError={setAuthnContextTagError}
+ isError={Boolean(authnContextTagError || error)}
/>
<FieldDescription>
AuthnContextClassRef values counted as MFA, in addition to the standard
two-factor classes. Press Enter to add.
</FieldDescription>
- <FieldError>{error?.message}</FieldError>
+ <FieldError>{authnContextTagError ?? error?.message}</FieldError>
</Field>
)}
/>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx
index 8eb13075f2..2ee11ee5d7 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx
@@ -2,6 +2,12 @@ import { ReactNode } from "react";
import { FieldDescription, FieldGroup, FieldLegend, FieldSet } from "@app/components/v3";
+// The backend matches signal values case-insensitively, so two casings of one value are the same entry.
+export const rejectDuplicateTag = (tag: string, existing: string[]) =>
+ existing.some((item) => item.toLowerCase() === tag.toLowerCase())
+ ? `${tag} is already listed`
+ : null;
+
export const FormSection = ({
title,
description,