Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor: update email trust configuration for LDAP and OIDC
Victor Hugo dos Santos18b048252c63
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.tsindex ba73d2423e..7e837f677c 100644--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts@@ -504,7 +504,7 @@ export const ldapConfigServiceFactory = ({// When the org enforces SSO, the verified domain + IdP are authoritative, so we skip the// separate email-verification step (the email-domain ownership check above already proves the// org owns this domain, and password signup is blocked for enforced domains).- const skipEmailVerification = Boolean(organization.authEnforced);+ const skipEmailVerification = Boolean(organization.authEnforced) || Boolean(serverCfg.trustLdapEmails);// A stale, still-unverified alias may point at another user's account. Don't mutate that// account's org membership / group state until the IdP proves control of it (thediff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.tsindex 9a10038db9..957e266e58 100644--- a/backend/src/ee/services/oidc/oidc-config-service.ts+++ b/backend/src/ee/services/oidc/oidc-config-service.ts@@ -585,7 +585,7 @@ export const oidcConfigServiceFactory = ({if (!isSmtpConnected) {throw new BadRequestError({message:- "Cannot enable OIDC when there are issues with the instance's SMTP configuration. Bypass this by turning on trust for OIDC emails in the server admin console."+ "Cannot enable OIDC when there are issues with the instance's SMTP configuration. Verify the instance's SMTP settings and try again."});}}diff --git a/backend/src/server/routes/v1/admin-router.ts b/backend/src/server/routes/v1/admin-router.tsindex 8628d69f27..76f107dcd5 100644--- a/backend/src/server/routes/v1/admin-router.ts+++ b/backend/src/server/routes/v1/admin-router.ts@@ -48,9 +48,7 @@ const SanitizedSuperAdminSchema = z.object({// Super admin-only fields (omitted for non-super-admin callers)instanceId: z.string().uuid().optional(),createdAt: z.date().optional(),- trustSamlEmails: z.boolean().nullish(),trustLdapEmails: z.boolean().nullish(),- trustOidcEmails: z.boolean().nullish(),onboardingCompleted: z.boolean().optional(),adminIdentityIds: z.string().array().nullable().optional(),fipsEnabled: z.boolean().optional(),@@ -157,9 +155,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {body: z.object({allowSignUp: z.boolean().optional(),allowedSignUpDomain: AllowedEmailDomainsSchema.optional().nullable(),- trustSamlEmails: z.boolean().optional(),trustLdapEmails: z.boolean().optional(),- trustOidcEmails: z.boolean().optional(),onboardingCompleted: z.boolean().optional(),defaultAuthOrgId: z.string().optional().nullable(),enabledLoginMethods: zdiff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.tsindex 2ec35d7547..128bf7a951 100644--- a/backend/src/services/super-admin/super-admin-service.ts+++ b/backend/src/services/super-admin/super-admin-service.ts@@ -474,6 +474,13 @@ export const superAdminServiceFactory = ({envOverridesUpdated = true;}+ // A caller that only sends fields this API no longer recognises (the removed trustSamlEmails /+ // trustOidcEmails switches, for instance) leaves nothing to write. Knex rejects an empty+ // update, so treat it as a no-op instead of failing the request.+ if (!Object.values(updatedData).some((value) => value !== undefined)) {+ return getServerCfg();+ }+const updatedServerCfg = await serverCfgDAL.updateById(ADMIN_CONFIG_DB_UUID, updatedData);try {diff --git a/docs/documentation/platform/admin-panel/server-admin.mdx b/docs/documentation/platform/admin-panel/server-admin.mdxindex 73ec4becb2..3a0712d1f1 100644--- a/docs/documentation/platform/admin-panel/server-admin.mdx+++ b/docs/documentation/platform/admin-panel/server-admin.mdx@@ -36,9 +36,11 @@ Signup can be restricted to users matching one or more email domains, such as yoIf you're using SAML/LDAP/OIDC for only one organization on your instance, you can specify a default organization to use at login to skip requiring users to manually enter the organization slug.-### Trust emails+### Trust LDAP emails-By default, users signing up through SAML/LDAP/OIDC will still need to verify their email address to prevent email spoofing. This requirement can be skipped by enabling the switch to trust logins through the respective method.+By default, users provisioned through LDAP must verify their email address on their first login, which prevents email spoofing. Enable **Trust LDAP emails** to skip that step for LDAP users across every organization on this instance.++For SAML and OIDC, email verification is skipped automatically when an organization [enforces SSO](/documentation/platform/sso/overview#sso-enforcement).### Broadcast messagesdiff --git a/docs/documentation/platform/ldap/overview.mdx b/docs/documentation/platform/ldap/overview.mdxindex a5a6a58af5..f465b44f80 100644--- a/docs/documentation/platform/ldap/overview.mdx+++ b/docs/documentation/platform/ldap/overview.mdx@@ -41,8 +41,9 @@ If the documentation for your required identity provider is not shown in the listhrough an external identity provider and requires an additional emailverification step upon their first login.- If you're running a self-hosted instance of Infisical and would like it to trust emails from external identity providers,- you can configure this behavior in the Server Admin Console.+ On a self-hosted instance, a server admin can skip this step by enabling **Trust LDAP emails** in the+ [Server Admin Console](/documentation/platform/admin-panel/server-admin#trust-ldap-emails). This applies to+ LDAP users in every organization on the instance.</Accordion></AccordionGroup>diff --git a/docs/documentation/platform/sso/overview.mdx b/docs/documentation/platform/sso/overview.mdxindex bcd1904eda..2b59f344b8 100644--- a/docs/documentation/platform/sso/overview.mdx+++ b/docs/documentation/platform/sso/overview.mdx@@ -75,10 +75,7 @@ This portal is accessible at `/login/admin` (e.g., https://app.infisical.com/logthrough an external identity provider and requires an additional emailverification step upon their first login.- If you're running a self-hosted instance of Infisical and would like it to trust emails from external identity providers,- you can configure this behavior in the Server Admin Console.-- This additional verification step is also skipped when your organization [enforces SSO](#sso-enforcement) for a [verified email domain](/documentation/platform/email-domain), since the verified domain and IdP are already authoritative for that email.+ To skip this step, [enforce SSO](#sso-enforcement) for your organization. Enforcement requires a [verified email domain](/documentation/platform/email-domain), so the domain and your identity provider are already authoritative for that email.</Accordion><Accordion title="Why do I get redirected to SSO when trying to use the Admin Login Portal?">You are likely being redirected because you do not have email authentication mode enabled, or you're not an **Organization Admin**. This portal requires **Organization Admin** status and direct credential login (email and password). **Server Admin** status alone is insufficient.diff --git a/frontend/src/hooks/api/admin/types.ts b/frontend/src/hooks/api/admin/types.tsindex 52921ded05..a79524748a 100644--- a/frontend/src/hooks/api/admin/types.ts+++ b/frontend/src/hooks/api/admin/types.ts@@ -93,9 +93,7 @@ export type TServerConfig = {// Super admin-only fields (omitted for non-super-admin callers)instanceId?: string;createdAt?: string;- trustSamlEmails?: boolean;trustLdapEmails?: boolean;- trustOidcEmails?: boolean;onboardingCompleted?: boolean;isSecretScanningDisabled?: boolean;kubernetesAutoFetchServiceAccountToken?: boolean;diff --git a/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx b/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsxindex 4d298e3f55..aa8cc0e103 100644--- a/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx+++ b/frontend/src/pages/admin/GeneralPage/components/GeneralPageForm.tsx@@ -40,9 +40,7 @@ enum SignUpModes {const formSchema = z.object({signUpMode: z.nativeEnum(SignUpModes),allowedSignUpDomain: allowedEmailDomainsSchema.optional().nullable(),- trustSamlEmails: z.boolean(),trustLdapEmails: z.boolean(),- trustOidcEmails: z.boolean(),defaultAuthOrgId: z.string(),authConsentContent: z.string().optional().default(""),pageFrameContent: z.string().optional().default("")@@ -65,9 +63,7 @@ export const GeneralPageForm = () => {// eslint-disable-next-linesignUpMode: config.allowSignUp ? SignUpModes.Anyone : SignUpModes.Disabled,allowedSignUpDomain: config.allowedSignUpDomain,- trustSamlEmails: config.trustSamlEmails ?? false,trustLdapEmails: config.trustLdapEmails ?? false,- trustOidcEmails: config.trustOidcEmails ?? false,defaultAuthOrgId: config.defaultAuthOrgId ?? "",authConsentContent: config.authConsentContent ?? "",pageFrameContent: config.pageFrameContent ?? ""@@ -80,22 +76,13 @@ export const GeneralPageForm = () => {const organizations = useGetOrganizations();const onFormSubmit = async (formData: TDashboardForm) => {- const {- allowedSignUpDomain,- trustSamlEmails,- trustLdapEmails,- trustOidcEmails,- authConsentContent,- pageFrameContent- } = formData;+ const { allowedSignUpDomain, trustLdapEmails, authConsentContent, pageFrameContent } = formData;await updateServerConfig({defaultAuthOrgId: formData.defaultAuthOrgId || null,allowSignUp: signUpMode !== SignUpModes.Disabled,allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,- trustSamlEmails,trustLdapEmails,- trustOidcEmails,authConsentContent,pageFrameContent});@@ -207,42 +194,30 @@ export const GeneralPageForm = () => {/><Separator />- <div>- <FieldTitle>Trust Emails</FieldTitle>- <FieldDescription>- Select if you want Infisical to trust external emails from SAML/LDAP/OIDC identity- providers. If set to false, then Infisical will prompt SAML/LDAP/OIDC provisioned- users to verify their email upon their first login.- </FieldDescription>- </div>- {(- [- ["trustSamlEmails", "SAML"],- ["trustLdapEmails", "LDAP"],- ["trustOidcEmails", "OIDC"]- ] as const- ).map(([name, label]) => (- <Controller- key={name}- control={control}- name={name}- render={({ field, fieldState: { error } }) => (- <Field orientation="horizontal">- <FieldContent>- <FieldTitle>Trust {label} emails</FieldTitle>- <FieldError>{error?.message}</FieldError>- </FieldContent>- <Switch- id={`trust-${label.toLowerCase()}-emails`}- aria-label={`Trust ${label} emails`}- variant="neutral"- checked={field.value}- onCheckedChange={field.onChange}- />- </Field>- )}- />- ))}+ <Controller+ control={control}+ name="trustLdapEmails"+ render={({ field, fieldState: { error } }) => (+ <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>Trust LDAP emails</FieldTitle>+ <FieldDescription>+ Trust email addresses provisioned by LDAP identity providers. When disabled,+ LDAP users must verify their email address on first login. SAML and OIDC users+ skip verification when their organization enforces SSO.+ </FieldDescription>+ <FieldError>{error?.message}</FieldError>+ </FieldContent>+ <Switch+ id="trust-ldap-emails"+ aria-label="Trust LDAP emails"+ variant="neutral"+ checked={field.value}+ onCheckedChange={field.onChange}+ />+ </Field>+ )}+ /><Separator /><div>