Skip to content

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

allow trusting idp mfa check

Thiago Araujo da Silva871119ac07f8
diff --git a/backend/AGENTS.md b/backend/AGENTS.md
index 0f6079c830..e0640115e3 100644
--- a/backend/AGENTS.md
+++ b/backend/AGENTS.md
@@ -297,6 +297,29 @@ If you encounter `API_KEY` or `SERVICE_TOKEN` in existing code, do not replicate
Token detection logic in `inject-identity.ts` checks `x-api-key` header first, then parses `Authorization: Bearer` and inspects JWT `authTokenType` field to determine mode.
+#### MFA for SSO logins
+
+`organizations.ssoMfaTrust` (`SsoMfaTrust` enum, `none` or `signal`) lets a SAML or OIDC login satisfy the
+org's MFA enforcement with the MFA the IdP already performed. The SAML and OIDC callbacks derive one verdict
+per login with `matchIdpMfaSignal` (`services/auth/idp-mfa-signal.ts`): the OIDC claim named by
+`oidc_configs.mfaClaimName` contains `mfa`, the SAML `AuthnContextClassRef` is a two-factor class, or the
+attribute named by `saml_configs.mfaSignalAttribute` contains `mfa`. Both names default to `amr`, and the
+per-config allowlists extend the built-in values rather than replace them. The verdict travels on the org-less
+session token as `idpMfaVerified`, and `selectOrganization` (`auth-login-service.ts`) applies it through
+`isIdpMfaTrusted` (`auth-fns.ts`), the only reader of the setting. Rules that must hold:
+
+- Enforcement is decided once per selection against the root org (`actorRootOrgId`), so moving between a root
+ org and its sub-orgs never re-prompts.
+- `isIdpMfaTrusted` refuses every non-SSO auth method, so password, Google and LDAP logins (break-glass
+ accounts) always get the Infisical challenge.
+- The trust only applies while `enforceMfa` is on. A user's own account-level MFA is still prompted. The
+ setting can be stored before enforcement is turned on; `updateOrg` refuses any value but `none` only while
+ the org has no active SAML or OIDC config.
+- `isMfaVerified` is never set from the IdP. It still means "proved a factor to Infisical", so step-up
+ (`mfa-step-up-fns.ts`) and PAM MFA are unaffected.
+- The callback writes a `USER_LOGIN` audit event with the raw `idpMfa` evidence, and `SELECT_ORGANIZATION`
+ records `mfaSatisfiedBy`, so an admin can see why a login was or wasn't prompted.
+
#### Delegated OAuth tokens
Two grants issue them: the authorization code flow (consented `scopes`) and the RFC 8693 token exchange
diff --git a/backend/e2e-test/routes/v3/auth-idp.spec.ts b/backend/e2e-test/routes/v3/auth-idp.spec.ts
index 15ad7d84db..93f2eb1d1d 100644
--- a/backend/e2e-test/routes/v3/auth-idp.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-idp.spec.ts
@@ -1,12 +1,15 @@
import crypto from "node:crypto";
+import { decode } from "jsonwebtoken";
import { Knex } from "knex";
-import { AccessScope, TableName } from "@app/db/schemas";
+import { AccessScope, OrgMembershipRole, TableName } from "@app/db/schemas";
import { seedData1 } from "@app/db/seed-data";
import { AuthMethod, ProviderAuthResult } from "@app/services/auth/auth-type";
+import { UserAliasType } from "@app/services/user-alias/user-alias-types";
import { cleanupEmailDomains, seedVerifiedEmailDomain } from "../../testUtils/email-domains";
+import { addUserMembership } from "../../testUtils/users";
const TEST_ORG_ID = seedData1.organization.id;
const TEST_DOMAIN = "testdomain.local";
@@ -37,6 +40,84 @@ describe("Auth IdP Service-Level Tests", () => {
await cleanupEmailDomains(TEST_ORG_ID, db);
});
+ // Covers the callback deriving the verdict; org selection acting on it is in auth-mfa.spec.ts.
+ describe("Identity provider MFA signal", () => {
+ const makeAcceptedSsoUser = async (aliasType: UserAliasType.SAML | UserAliasType.OIDC) => {
+ const externalId = `${aliasType}-signal-${crypto.randomUUID()}`;
+ const email = `${aliasType}signal-${crypto.randomUUID()}@${TEST_DOMAIN}`;
+ const db = getDb();
+
+ const [user] = await db(TableName.Users)
+ .insert({
+ username: email,
+ email,
+ firstName: "Signal",
+ lastName: "User",
+ isAccepted: true,
+ isGhost: false,
+ authMethods: [aliasType === UserAliasType.SAML ? AuthMethod.OKTA_SAML : AuthMethod.OIDC]
+ })
+ .returning("*");
+ createdUserIds.push(user.id);
+
+ await db(TableName.UserAliases).insert({
+ userId: user.id,
+ username: email,
+ aliasType,
+ externalId,
+ emails: [email],
+ orgId: TEST_ORG_ID,
+ isEmailVerified: true
+ });
+ await addUserMembership({ userId: user.id, orgId: TEST_ORG_ID, role: OrgMembershipRole.Member });
+
+ return { externalId, email };
+ };
+
+ const sessionClaims = (result: { result: string; tokens?: { access: string } }) => {
+ expect(result.result).toBe(ProviderAuthResult.SESSION);
+ return decode(result.tokens?.access as string) as Record<string, unknown>;
+ };
+
+ test("a SAML login carries the verdict on its session, and only when the IdP signalled MFA", async () => {
+ const { externalId, email } = await makeAcceptedSsoUser(UserAliasType.SAML);
+ const login = (idpMfa?: { verified: boolean; evidence: string[] }) =>
+ getServices().saml.samlLogin({
+ externalId,
+ email,
+ firstName: "Signal",
+ lastName: "User",
+ authProvider: AuthMethod.OKTA_SAML,
+ orgId: TEST_ORG_ID,
+ ip: "127.0.0.1",
+ userAgent: "test-agent",
+ idpMfa
+ });
+
+ expect(sessionClaims(await login({ verified: true, evidence: ["amr=mfa"] })).idpMfaVerified).toBe(true);
+ expect(sessionClaims(await login({ verified: false, evidence: [] })).idpMfaVerified).toBeUndefined();
+ expect(sessionClaims(await login()).idpMfaVerified).toBeUndefined();
+ });
+
+ test("an OIDC login carries the verdict on its session, and only when the IdP signalled MFA", async () => {
+ const { externalId, email } = await makeAcceptedSsoUser(UserAliasType.OIDC);
+ const login = (idpMfa?: { verified: boolean; evidence: string[] }) =>
+ getServices().oidc.oidcLogin({
+ externalId,
+ email,
+ firstName: "Signal",
+ lastName: "User",
+ orgId: TEST_ORG_ID,
+ ip: "127.0.0.1",
+ userAgent: "test-agent",
+ idpMfa
+ });
+
+ expect(sessionClaims(await login({ verified: true, evidence: ["mfa"] })).idpMfaVerified).toBe(true);
+ expect(sessionClaims(await login()).idpMfaVerified).toBeUndefined();
+ });
+ });
+
describe("SAML Login", () => {
test("Creates new user + alias + membership as Invited", async () => {
const externalId = `saml-ext-${crypto.randomUUID()}`;
diff --git a/backend/e2e-test/routes/v3/auth-mfa.spec.ts b/backend/e2e-test/routes/v3/auth-mfa.spec.ts
index 69c0afe366..c13590b088 100644
--- a/backend/e2e-test/routes/v3/auth-mfa.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-mfa.spec.ts
@@ -1,11 +1,12 @@
-import { decode } from "jsonwebtoken";
+import jwt, { decode } from "jsonwebtoken";
import { TableName } from "@app/db/schemas";
import { seedData1 } from "@app/db/seed-data";
-import { MfaMethod } from "@app/services/auth/auth-type";
+import { AuthMethod, AuthTokenType, MfaMethod, SsoMfaTrust } from "@app/services/auth/auth-type";
import { TTestSmtpService } from "../../mocks/smtp";
import { loginUser, selectOrg } from "../../testUtils/auth";
+import { overrideLicenseFeatures } from "../../testUtils/license";
describe("Auth MFA V3", () => {
const smtp = () => (globalThis as unknown as { testSmtp: TTestSmtpService }).testSmtp;
@@ -97,4 +98,134 @@ describe("Auth MFA V3", () => {
expect(res.statusCode).toBeGreaterThanOrEqual(400);
});
+
+ // Signs the org-less session directly; the callback deriving the verdict is in auth-idp.spec.ts.
+ describe("identity provider MFA signal", () => {
+ const rootOrgId = seedData1.organization.id;
+ let restoreLicense: () => void;
+
+ const signSsoSession = async (authMethod: AuthMethod, idpMfaVerified?: boolean) => {
+ const [session] = await db()(TableName.AuthTokenSession)
+ .insert({
+ userId: seedData1.id,
+ ip: "127.0.0.1",
+ userAgent: "e2e-idp-mfa-signal",
+ accessVersion: 1,
+ refreshVersion: 1,
+ lastUsed: new Date()
+ } as never)
+ .returning("*");
+
+ return jwt.sign(
+ {
+ authTokenType: AuthTokenType.ACCESS_TOKEN,
+ authMethod,
+ userId: seedData1.id,
+ tokenVersionId: session.id,
+ accessVersion: 1,
+ ...(idpMfaVerified && { idpMfaVerified })
+ },
+ process.env.AUTH_SECRET as string,
+ { expiresIn: "1h" }
+ );
+ };
+
+ const setSsoMfaTrust = (ssoMfaTrust: SsoMfaTrust) =>
+ db()(TableName.Organization).where({ id: rootOrgId }).update({ ssoMfaTrust });
+
+ const updateOrg = (body: Record<string, unknown>) =>
+ testServer.inject({
+ method: "PATCH",
+ url: `/api/v1/organization/${rootOrgId}`,
+ headers: { authorization: `Bearer ${jwtAuthToken}` },
+ body
+ });
+
+ beforeAll(() => {
+ restoreLicense = overrideLicenseFeatures({ enforceMfa: true });
+ });
+
+ afterAll(async () => {
+ restoreLicense();
+ await setSsoMfaTrust(SsoMfaTrust.None);
+ });
+
+ test.each([AuthMethod.OKTA_SAML, AuthMethod.OIDC])(
+ "a signalled %s session skips the prompt when the org trusts the signal",
+ async (authMethod) => {
+ await setSsoMfaTrust(SsoMfaTrust.Signal);
+
+ const { payload } = await selectOrg(await signSsoSession(authMethod, true), rootOrgId);
+
+ expect(payload.isMfaEnabled).toBe(false);
+ expect(decode(payload.token)).toMatchObject({ organizationId: rootOrgId, idpMfaVerified: true });
+ }
+ );
+
+ test("an SSO session that carried no signal still gets the prompt", async () => {
+ await setSsoMfaTrust(SsoMfaTrust.Signal);
+
+ const { payload } = await selectOrg(await signSsoSession(AuthMethod.OKTA_SAML), rootOrgId);
+
+ expect(payload.isMfaEnabled).toBe(true);
+ expect(payload.mfaMethod).toBe(MfaMethod.EMAIL);
+ });
+
+ test("a password session on the same org still gets the prompt", async () => {
+ await setSsoMfaTrust(SsoMfaTrust.Signal);
+ const { accessToken } = await loginUser(seedData1.email, seedData1.password);
+
+ const { payload } = await selectOrg(accessToken, rootOrgId);
+
+ expect(payload.isMfaEnabled).toBe(true);
+ });
+
+ test("the signal is ignored while the org requires Infisical MFA", async () => {
+ await setSsoMfaTrust(SsoMfaTrust.None);
+
+ const { payload } = await selectOrg(await signSsoSession(AuthMethod.OKTA_SAML, true), rootOrgId);
+
+ expect(payload.isMfaEnabled).toBe(true);
+ });
+
+ test("the setting cannot be turned on without an active SSO configuration", async () => {
+ const res = await updateOrg({ ssoMfaTrust: SsoMfaTrust.Signal });
+
+ expect(res.statusCode).toBe(400);
+ expect(res.json().message).toMatch(/SAML or OIDC/);
+ });
+
+ test("a user's own MFA is still prompted when only the user, not the org, requires it", async () => {
+ await setSsoMfaTrust(SsoMfaTrust.Signal);
+ await db()(TableName.Organization).where({ id: rootOrgId }).update({ enforceMfa: false });
+ await db()(TableName.Users).where({ id: seedData1.id }).update({ isMfaEnabled: true });
+ try {
+ const { payload } = await selectOrg(await signSsoSession(AuthMethod.OKTA_SAML, true), rootOrgId);
+
+ expect(payload.isMfaEnabled).toBe(true);
+ } finally {
+ await db()(TableName.Users).where({ id: seedData1.id }).update({ isMfaEnabled: false });
+ await db()(TableName.Organization).where({ id: rootOrgId }).update({ enforceMfa: true });
+ }
+ });
+
+ test("an unknown mode is rejected", async () => {
+ const res = await updateOrg({ ssoMfaTrust: "delegate" });
+
+ expect(res.statusCode).toBe(422);
+ });
+
+ test("the setting can be turned off even on a plan without MFA enforcement", async () => {
+ await setSsoMfaTrust(SsoMfaTrust.Signal);
+ restoreLicense();
+ try {
+ const res = await updateOrg({ ssoMfaTrust: SsoMfaTrust.None });
+
+ expect(res.statusCode).toBe(200);
+ expect(res.json().organization.ssoMfaTrust).toBe(SsoMfaTrust.None);
+ } finally {
+ restoreLicense = overrideLicenseFeatures({ enforceMfa: true });
+ }
+ });
+ });
});
diff --git a/backend/src/db/migrations/20261029195045_sso-mfa-trust.ts b/backend/src/db/migrations/20261029195045_sso-mfa-trust.ts
new file mode 100644
index 0000000000..7662106861
--- /dev/null
+++ b/backend/src/db/migrations/20261029195045_sso-mfa-trust.ts
@@ -0,0 +1,55 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ if (!(await knex.schema.hasColumn(TableName.Organization, "ssoMfaTrust"))) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.string("ssoMfaTrust", 20).notNullable().defaultTo("none");
+ });
+ }
+
+ const hasSamlSignalAttribute = await knex.schema.hasColumn(TableName.SamlConfig, "mfaSignalAttribute");
+ const hasSamlAuthnContexts = await knex.schema.hasColumn(TableName.SamlConfig, "mfaAuthnContexts");
+ if (!hasSamlSignalAttribute || !hasSamlAuthnContexts) {
+ await knex.schema.alterTable(TableName.SamlConfig, (t) => {
+ if (!hasSamlSignalAttribute) t.string("mfaSignalAttribute", 512).notNullable().defaultTo("amr");
+ if (!hasSamlAuthnContexts) t.specificType("mfaAuthnContexts", "text[]").nullable();
+ });
+ }
+
+ const hasOidcClaimName = await knex.schema.hasColumn(TableName.OidcConfig, "mfaClaimName");
+ const hasOidcAmrValues = await knex.schema.hasColumn(TableName.OidcConfig, "mfaAmrValues");
+ if (!hasOidcClaimName || !hasOidcAmrValues) {
+ await knex.schema.alterTable(TableName.OidcConfig, (t) => {
+ if (!hasOidcClaimName) t.string("mfaClaimName", 128).notNullable().defaultTo("amr");
+ if (!hasOidcAmrValues) t.specificType("mfaAmrValues", "text[]").nullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasOidcClaimName = await knex.schema.hasColumn(TableName.OidcConfig, "mfaClaimName");
+ const hasOidcAmrValues = await knex.schema.hasColumn(TableName.OidcConfig, "mfaAmrValues");
+ if (hasOidcClaimName || hasOidcAmrValues) {
+ await knex.schema.alterTable(TableName.OidcConfig, (t) => {
+ if (hasOidcClaimName) t.dropColumn("mfaClaimName");
+ if (hasOidcAmrValues) t.dropColumn("mfaAmrValues");
+ });
+ }
+
+ const hasSamlSignalAttribute = await knex.schema.hasColumn(TableName.SamlConfig, "mfaSignalAttribute");
+ const hasSamlAuthnContexts = await knex.schema.hasColumn(TableName.SamlConfig, "mfaAuthnContexts");
+ if (hasSamlSignalAttribute || hasSamlAuthnContexts) {
+ await knex.schema.alterTable(TableName.SamlConfig, (t) => {
+ if (hasSamlSignalAttribute) t.dropColumn("mfaSignalAttribute");
+ if (hasSamlAuthnContexts) t.dropColumn("mfaAuthnContexts");
+ });
+ }
+
+ if (await knex.schema.hasColumn(TableName.Organization, "ssoMfaTrust")) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.dropColumn("ssoMfaTrust");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/oidc-configs.ts b/backend/src/db/schemas/oidc-configs.ts
index 216b50847a..aacccd097f 100644
--- a/backend/src/db/schemas/oidc-configs.ts
+++ b/backend/src/db/schemas/oidc-configs.ts
@@ -33,7 +33,9 @@ export const OidcConfigsSchema = z.object({
manageGroupMemberships: z.boolean().default(false),
encryptedOidcClientId: zodBuffer,
encryptedOidcClientSecret: zodBuffer,
- jwtSignatureAlgorithm: z.string().default("RS256")
+ jwtSignatureAlgorithm: z.string().default("RS256"),
+ mfaClaimName: z.string().default("amr"),
+ mfaAmrValues: z.string().array().nullable().optional()
});
export type TOidcConfigs = z.infer<typeof OidcConfigsSchema>;
diff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.ts
index d61d716466..9ba2c01648 100644
--- a/backend/src/db/schemas/organizations.ts
+++ b/backend/src/db/schemas/organizations.ts
@@ -46,7 +46,8 @@ export const OrganizationsSchema = z.object({
allowCrossProjectSecretSharing: z.boolean().default(false),
createdByUserId: z.string().uuid().nullable().optional(),
orgWideSecretValueTrackingEnabled: z.boolean().default(false),
- requireGatewayPools: z.boolean().default(false)
+ requireGatewayPools: z.boolean().default(false),
+ ssoMfaTrust: z.string().default("none")
});
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
diff --git a/backend/src/db/schemas/saml-configs.ts b/backend/src/db/schemas/saml-configs.ts
index de85653c2e..42772ee721 100644
--- a/backend/src/db/schemas/saml-configs.ts
+++ b/backend/src/db/schemas/saml-configs.ts
@@ -29,7 +29,9 @@ export const SamlConfigsSchema = z.object({
encryptedSamlEntryPoint: zodBuffer,
encryptedSamlIssuer: zodBuffer,
encryptedSamlCertificate: zodBuffer,
- enableGroupSync: z.boolean().default(false)
+ enableGroupSync: z.boolean().default(false),
+ mfaSignalAttribute: z.string().default("amr"),
+ mfaAuthnContexts: z.string().array().nullable().optional()
});
export type TSamlConfigs = z.infer<typeof SamlConfigsSchema>;
diff --git a/backend/src/db/seed-oidc.ts b/backend/src/db/seed-oidc.ts
index b16a8b46e6..2e517907b9 100644
--- a/backend/src/db/seed-oidc.ts
+++ b/backend/src/db/seed-oidc.ts
@@ -249,10 +249,15 @@ const main = async () => {
orgId: org.id,
configurationType: "discoveryURL",
discoveryURL,
+ issuer: "",
+ authorizationEndpoint: "",
+ jwksUri: "",
+ tokenEndpoint: "",
+ userinfoEndpoint: "",
isActive: true,
jwtSignatureAlgorithm,
manageGroupMemberships: false,
- allowedEmailDomains: null,
+ allowedEmailDomains: "",
encryptedOidcClientId: encryptor({ plainText: Buffer.from(clientId) }).cipherTextBlob,
encryptedOidcClientSecret: encryptor({ plainText: Buffer.from(clientSecret) }).cipherTextBlob
});
diff --git a/backend/src/ee/routes/v1/oidc-router.ts b/backend/src/ee/routes/v1/oidc-router.ts
index 7c85c7863e..304a37156a 100644
--- a/backend/src/ee/routes/v1/oidc-router.ts
+++ b/backend/src/ee/routes/v1/oidc-router.ts
@@ -37,9 +37,14 @@ const SanitizedOidcConfigSchema = OidcConfigsSchema.pick({
isActive: true,
allowedEmailDomains: true,
manageGroupMemberships: true,
- jwtSignatureAlgorithm: true
+ jwtSignatureAlgorithm: true,
+ mfaClaimName: true,
+ mfaAmrValues: true
});
+const OidcMfaAmrValuesSchema = z.array(z.string().trim().min(1).max(64)).max(20).nullable().optional();
+const OidcMfaClaimNameSchema = z.string().trim().min(1).max(128).optional();
+
export const registerOidcRouter = async (server: FastifyZodProvider) => {
const appCfg = getConfig();
const passport = new Authenticator({ key: "oidc", userProperty: "passportUser" });
@@ -230,7 +235,9 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
orgId: true,
allowedEmailDomains: true,
manageGroupMemberships: true,
- jwtSignatureAlgorithm: true
+ jwtSignatureAlgorithm: true,
+ mfaClaimName: true,
+ mfaAmrValues: true
}).extend({
clientId: z.string(),
clientSecret: z.string()
@@ -294,6 +301,8 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
clientId: z.string().trim().describe(OidcSSo.UPDATE_CONFIG.clientId),
clientSecret: z.string().trim().describe(OidcSSo.UPDATE_CONFIG.clientSecret),
isActive: z.boolean().describe(OidcSSo.UPDATE_CONFIG.isActive),
+ mfaClaimName: OidcMfaClaimNameSchema.describe(OidcSSo.UPDATE_CONFIG.mfaClaimName),
+ mfaAmrValues: OidcMfaAmrValuesSchema.describe(OidcSSo.UPDATE_CONFIG.mfaAmrValues),
manageGroupMemberships: z.boolean().optional().describe(OidcSSo.UPDATE_CONFIG.manageGroupMemberships),
jwtSignatureAlgorithm: z
.nativeEnum(OIDCJWTSignatureAlgorithm)
@@ -315,7 +324,9 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
orgId: true,
allowedEmailDomains: true,
isActive: true,
- manageGroupMemberships: true
+ manageGroupMemberships: true,
+ mfaClaimName: true,
+ mfaAmrValues: true
})
}
},
@@ -394,6 +405,8 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
clientSecret: z.string().trim().describe(OidcSSo.CREATE_CONFIG.clientSecret),
isActive: z.boolean().describe(OidcSSo.CREATE_CONFIG.isActive),
organizationId: z.string().trim().describe(OidcSSo.CREATE_CONFIG.organizationId),
+ mfaClaimName: OidcMfaClaimNameSchema.describe(OidcSSo.CREATE_CONFIG.mfaClaimName),
+ mfaAmrValues: OidcMfaAmrValuesSchema.describe(OidcSSo.CREATE_CONFIG.mfaAmrValues),
manageGroupMemberships: z
.boolean()
.optional()
diff --git a/backend/src/ee/routes/v1/saml-router.ts b/backend/src/ee/routes/v1/saml-router.ts
index b860241ce8..d494c815a7 100644
--- a/backend/src/ee/routes/v1/saml-router.ts
+++ b/backend/src/ee/routes/v1/saml-router.ts
@@ -32,8 +32,12 @@ import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { SanitizedSamlConfigSchema } from "@app/server/routes/sanitizedSchema/directory-config";
import { AuthMode, ProviderAuthResult, TProviderAuthCallback } from "@app/services/auth/auth-type";
+import { extractSamlAuthnContextClassRefs, matchIdpMfaSignal } from "@app/services/auth/idp-mfa-signal";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
+const SamlMfaSignalAttributeSchema = z.string().trim().min(1).max(512).optional();
+const SamlMfaAuthnContextsSchema = z.array(z.string().trim().min(1).max(512)).max(20).nullable().optional();
+
type TSAMLConfig = {
callbackUrl: string;
entryPoint: string;
@@ -188,17 +192,26 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
logger.error(err, "Relay state parsing failed");
}
+ const { ssoConfig } = req as unknown as FastifyRequest;
+ const idpMfa = matchIdpMfaSignal({
+ kind: "saml",
+ authnContextClassRefs: extractSamlAuthnContextClassRefs(profile.getAssertion?.()),
+ attributes: profile.attributes as Record<string, unknown> | undefined,
+ config: ssoConfig
+ });
+
const loginResult = await server.services.saml.samlLogin({
externalId: profile.nameID,
email: email.toLowerCase(),
firstName,
lastName: lastName as string,
callbackPort: callbackPort || undefined,
- authProvider: (req as unknown as FastifyRequest).ssoConfig?.authProvider,
- orgId: (req as unknown as FastifyRequest).ssoConfig?.orgId,
+ authProvider: ssoConfig?.authProvider,
+ orgId: ssoConfig?.orgId,
ip: requestContext.get("ip") || "",
userAgent: requestContext.get("userAgent") || "",
- metadata: userMetadata
+ metadata: userMetadata,
+ idpMfa
});
cb(null, loginResult);
@@ -433,7 +446,9 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
issuer: z.string(),
cert: z.string(),
lastUsed: z.date().nullable().optional(),
- enableGroupSync: z.boolean().optional()
+ enableGroupSync: z.boolean().optional(),
+ mfaSignalAttribute: z.string(),
+ mfaAuthnContexts: z.string().array().nullable().optional()
})
}
},
@@ -474,14 +489,25 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
entryPoint: z.string().trim().describe(SamlSso.CREATE_CONFIG.entryPoint),
issuer: z.string().trim().describe(SamlSso.CREATE_CONFIG.issuer),
cert: z.string().trim().describe(SamlSso.CREATE_CONFIG.cert),
- enableGroupSync: z.boolean().optional().describe(SamlSso.CREATE_CONFIG.enableGroupSync)
+ enableGroupSync: z.boolean().optional().describe(SamlSso.CREATE_CONFIG.enableGroupSync),
+ mfaSignalAttribute: SamlMfaSignalAttributeSchema.describe(SamlSso.CREATE_CONFIG.mfaSignalAttribute),
+ mfaAuthnContexts: SamlMfaAuthnContextsSchema.describe(SamlSso.CREATE_CONFIG.mfaAuthnContexts)
}),
response: {
200: SanitizedSamlConfigSchema
}
},
handler: async (req) => {
- const { isActive, authProvider, issuer, entryPoint, cert, enableGroupSync } = req.body;
+ const {
+ isActive,
+ authProvider,
+ issuer,
+ entryPoint,
+ cert,
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
+ } = req.body;
const { permission } = req;
const samlCfg = await server.services.saml.createSamlCfg({
@@ -491,6 +517,8 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
entryPoint,
idpCert: cert,
enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts,
actor: permission.type,
actorId: permission.id,
actorAuthMethod: permission.authMethod,
@@ -539,7 +567,9 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
entryPoint: z.string().trim().describe(SamlSso.UPDATE_CONFIG.entryPoint),
issuer: z.string().trim().describe(SamlSso.UPDATE_CONFIG.issuer),
cert: z.string().trim().describe(SamlSso.UPDATE_CONFIG.cert),
- enableGroupSync: z.boolean().optional().describe(SamlSso.UPDATE_CONFIG.enableGroupSync)
+ enableGroupSync: z.boolean().optional().describe(SamlSso.UPDATE_CONFIG.enableGroupSync),
+ mfaSignalAttribute: SamlMfaSignalAttributeSchema.describe(SamlSso.UPDATE_CONFIG.mfaSignalAttribute),
+ mfaAuthnContexts: SamlMfaAuthnContextsSchema.describe(SamlSso.UPDATE_CONFIG.mfaAuthnContexts)
})
.partial()
.merge(z.object({ organizationId: z.string().trim().describe(SamlSso.UPDATE_CONFIG.organizationId) })),
@@ -548,7 +578,16 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
}
},
handler: async (req) => {
- const { isActive, authProvider, issuer, entryPoint, cert, enableGroupSync } = req.body;
+ const {
+ isActive,
+ authProvider,
+ issuer,
+ entryPoint,
+ cert,
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
+ } = req.body;
const { permission } = req;
const samlCfg = await server.services.saml.updateSamlCfg({
@@ -558,6 +597,8 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
entryPoint,
idpCert: cert,
enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts,
actor: permission.type,
actorId: permission.id,
actorAuthMethod: permission.authMethod,
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 5b7389729c..86c3951125 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -39,6 +39,7 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums
import { TCreateAppConnectionDTO, TUpdateAppConnectionDTO } from "@app/services/app-connection/app-connection-types";
import { TApprovalRequestSubjectMetadata } from "@app/services/approval-policy/approval-policy-types";
import { ActorType } from "@app/services/auth/auth-type";
+import { TIdpMfaSignal } from "@app/services/auth/idp-mfa-signal";
import { CaStatus } from "@app/services/certificate-authority/certificate-authority-enums";
import { CertificateIssuanceOperation } from "@app/services/certificate-common/certificate-constants";
import { EnrollmentType } from "@app/services/certificate-profile/certificate-profile-types";
@@ -3721,11 +3722,14 @@ interface OrgAdminBypassSSOEvent {
metadata: Record<string, string>; // no metadata yet
}
+type TMfaSatisfiedBy = "not-required" | "infisical" | "idp";
+
interface UserLoginEvent {
type: EventType.USER_LOGIN;
metadata: {
organizationId?: string;
authProvider?: string;
+ idpMfa?: TIdpMfaSignal;
};
}
@@ -3734,6 +3738,7 @@ interface SelectOrganizationEvent {
metadata: {
organizationId: string;
organizationName: string;
+ mfaSatisfiedBy?: TMfaSatisfiedBy;
};
}
@@ -3743,6 +3748,7 @@ interface SelectSubOrganizationEvent {
organizationId: string;
organizationName: string;
rootOrganizationId: string;
+ mfaSatisfiedBy?: TMfaSatisfiedBy;
};
}
diff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.ts
index 9fb17cae91..37f5608383 100644
--- a/backend/src/ee/services/oidc/oidc-config-service.ts
+++ b/backend/src/ee/services/oidc/oidc-config-service.ts
@@ -41,6 +41,7 @@ import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-se
import { TokenType } from "@app/services/auth-token/auth-token-types";
import { TAuthLoginFactory } from "@app/services/auth/auth-login-service";
import { ActorType, AuthMethod } from "@app/services/auth/auth-type";
+import { matchIdpMfaSignal } from "@app/services/auth/idp-mfa-signal";
import { TEventEmitter } from "@app/services/event-outbox/event-outbox-types";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
@@ -215,7 +216,9 @@ export const oidcConfigServiceFactory = ({
clientId,
clientSecret,
manageGroupMemberships: oidcCfg.manageGroupMemberships,
- jwtSignatureAlgorithm: oidcCfg.jwtSignatureAlgorithm
+ jwtSignatureAlgorithm: oidcCfg.jwtSignatureAlgorithm,
+ mfaClaimName: oidcCfg.mfaClaimName,
+ mfaAmrValues: oidcCfg.mfaAmrValues
};
};
@@ -229,7 +232,8 @@ export const oidcConfigServiceFactory = ({
userAgent,
callbackPort,
groups = [],
- manageGroupMemberships
+ manageGroupMemberships,
+ idpMfa
}: TOidcLoginDTO) => {
const serverCfg = await getServerCfg();
@@ -602,7 +606,8 @@ export const oidcConfigServiceFactory = ({
ip,
userAgent,
organizationId: organization.id,
- callbackPort: callbackPort ? Number(callbackPort) : undefined
+ callbackPort: callbackPort ? Number(callbackPort) : undefined,
+ idpMfa
});
return { ...callbackResult, userId: user.id };
@@ -626,7 +631,9 @@ export const oidcConfigServiceFactory = ({
clientId,
clientSecret,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
}: TUpdateOidcCfgDTO) => {
const org = await orgDAL.findOne({ id: organizationId });
@@ -700,7 +707,9 @@ export const oidcConfigServiceFactory = ({
isActive,
lastUsed: null,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
};
if (clientId !== undefined) {
@@ -735,7 +744,9 @@ export const oidcConfigServiceFactory = ({
clientId,
clientSecret,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
}: TCreateOidcCfgDTO) => {
const org = await orgDAL.findOne({ id: organizationId });
if (!org) {
@@ -799,6 +810,8 @@ export const oidcConfigServiceFactory = ({
orgId: org.id,
manageGroupMemberships,
jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues,
encryptedOidcClientId: encryptor({ plainText: Buffer.from(clientId) }).cipherTextBlob,
encryptedOidcClientSecret: encryptor({ plainText: Buffer.from(clientSecret) }).cipherTextBlob
});
@@ -933,7 +946,8 @@ export const oidcConfigServiceFactory = ({
userAgent: requestContext.get("userAgent") || "",
groups,
callbackPort,
- manageGroupMemberships: oidcCfg.manageGroupMemberships
+ manageGroupMemberships: oidcCfg.manageGroupMemberships,
+ idpMfa: matchIdpMfaSignal({ kind: "oidc", claims, config: oidcCfg })
})
.then((loginResult) => {
cb(null, loginResult);
diff --git a/backend/src/ee/services/oidc/oidc-config-types.ts b/backend/src/ee/services/oidc/oidc-config-types.ts
index fb1bdd57fa..6400e40618 100644
--- a/backend/src/ee/services/oidc/oidc-config-types.ts
+++ b/backend/src/ee/services/oidc/oidc-config-types.ts
@@ -1,4 +1,5 @@
import { TGenericPermission } from "@app/lib/types";
+import { TIdpMfaSignal } from "@app/services/auth/idp-mfa-signal";
export enum OIDCConfigurationType {
CUSTOM = "custom",
@@ -23,6 +24,7 @@ export type TOidcLoginDTO = {
callbackPort?: string;
groups?: string[];
manageGroupMemberships?: boolean | null;
+ idpMfa?: TIdpMfaSignal;
};
export type TGetOidcCfgDTO =
@@ -50,6 +52,8 @@ export type TCreateOidcCfgDTO = {
organizationId: string;
manageGroupMemberships: boolean;
jwtSignatureAlgorithm: OIDCJWTSignatureAlgorithm;
+ mfaClaimName?: string;
+ mfaAmrValues?: string[] | null;
} & TGenericPermission;
export type TUpdateOidcCfgDTO = Partial<{
@@ -67,5 +71,7 @@ export type TUpdateOidcCfgDTO = Partial<{
organizationId: string;
manageGroupMemberships: boolean;
jwtSignatureAlgorithm: OIDCJWTSignatureAlgorithm;
+ mfaClaimName: string;
+ mfaAmrValues: string[] | null;
}> &
TGenericPermission;
diff --git a/backend/src/ee/services/saml-config/saml-config-service.ts b/backend/src/ee/services/saml-config/saml-config-service.ts
index 8045aec1fb..92d830d7cb 100644
--- a/backend/src/ee/services/saml-config/saml-config-service.ts
+++ b/backend/src/ee/services/saml-config/saml-config-service.ts
@@ -298,7 +298,9 @@ export const samlConfigServiceFactory = ({
isActive,
entryPoint,
authProvider,
- enableGroupSync
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
}) => {
const { permission } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.ParentOrganization,
@@ -354,7 +356,9 @@ export const samlConfigServiceFactory = ({
encryptedSamlCertificate: encryptor({ plainText: Buffer.from(idpCert) }).cipherTextBlob,
encryptedSamlEntryPoint: encryptor({ plainText: Buffer.from(entryPoint) }).cipherTextBlob,
encryptedSamlIssuer: encryptor({ plainText: Buffer.from(issuer) }).cipherTextBlob,
- enableGroupSync: enableGroupSync || false
+ enableGroupSync: enableGroupSync || false,
+ mfaSignalAttribute,
+ mfaAuthnContexts
});
recordSsoConfigChangeMetric({ provider: SsoProvider.Saml, action: SsoConfigAction.Create, orgId });
@@ -373,7 +377,9 @@ export const samlConfigServiceFactory = ({
isActive,
entryPoint,
authProvider,
- enableGroupSync
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
}) => {
const { permission } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.ParentOrganization,
@@ -425,6 +431,12 @@ export const samlConfigServiceFactory = ({
if (enableGroupSync !== undefined) {
updateQuery.enableGroupSync = enableGroupSync;
}
+ if (mfaSignalAttribute !== undefined) {
+ updateQuery.mfaSignalAttribute = mfaSignalAttribute;
+ }
+ if (mfaAuthnContexts !== undefined) {
+ updateQuery.mfaAuthnContexts = mfaAuthnContexts;
+ }
const { encryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
orgId
@@ -535,7 +547,9 @@ export const samlConfigServiceFactory = ({
issuer,
cert,
lastUsed: samlConfig.lastUsed,
- enableGroupSync: samlConfig.enableGroupSync
+ enableGroupSync: samlConfig.enableGroupSync,
+ mfaSignalAttribute: samlConfig.mfaSignalAttribute,
+ mfaAuthnContexts: samlConfig.mfaAuthnContexts
};
};
@@ -549,7 +563,8 @@ export const samlConfigServiceFactory = ({
ip,
userAgent,
callbackPort,
- metadata
+ metadata,
+ idpMfa
}) => {
const serverCfg = await getServerCfg();
@@ -843,7 +858,8 @@ export const samlConfigServiceFactory = ({
ip,
userAgent,
organizationId: organization.id,
- callbackPort
+ callbackPort,
+ idpMfa
});
return { ...callbackResult, userId: user.id, orgId: organization.id, orgName: organization.name };
diff --git a/backend/src/ee/services/saml-config/saml-config-types.ts b/backend/src/ee/services/saml-config/saml-config-types.ts
index e20e613d6e..2daf00ed3f 100644
--- a/backend/src/ee/services/saml-config/saml-config-types.ts
+++ b/backend/src/ee/services/saml-config/saml-config-types.ts
@@ -2,6 +2,7 @@ import { TSamlConfigs } from "@app/db/schemas";
import { TOrgPermission } from "@app/lib/types";
import { TProviderAuthResult } from "@app/services/auth/auth-login-type";
import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";
+import { TIdpMfaSignal } from "@app/services/auth/idp-mfa-signal";
export enum SamlProviders {
OKTA_SAML = "okta-saml",
@@ -19,6 +20,8 @@ export type TCreateSamlCfgDTO = {
issuer: string;
idpCert: string;
enableGroupSync?: boolean;
+ mfaSignalAttribute?: string;
+ mfaAuthnContexts?: string[] | null;
} & TOrgPermission;
export type TUpdateSamlCfgDTO = Partial<{
@@ -28,6 +31,8 @@ export type TUpdateSamlCfgDTO = Partial<{
issuer: string;
idpCert: string;
enableGroupSync?: boolean;
+ mfaSignalAttribute?: string;
+ mfaAuthnContexts?: string[] | null;
}> &
TOrgPermission;
@@ -65,6 +70,7 @@ export type TSamlLoginDTO = {
// saml thingy
callbackPort?: number;
metadata?: { key: string; value: string }[];
+ idpMfa?: TIdpMfaSignal;
};
export type TSamlConfigServiceFactory = {
@@ -81,6 +87,8 @@ export type TSamlConfigServiceFactory = {
cert: string;
lastUsed: Date | null | undefined;
enableGroupSync?: boolean;
+ mfaSignalAttribute: string;
+ mfaAuthnContexts?: string[] | null;
}>;
samlLogin: (arg: TSamlLoginDTO) => Promise<TProviderAuthResult & { userId: string; orgId: string; orgName: string }>;
};
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 94e5b19bbc..5b9d818f5d 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -4206,7 +4206,9 @@ export const OidcSSo = {
isActive: "Whether to enable or disable this OIDC configuration.",
manageGroupMemberships:
"Whether to manage group memberships for the OIDC configuration. If enabled, users will automatically be assigned groups when they sign in, based on which groups they are a member of in the OIDC provider.",
- jwtSignatureAlgorithm: "The algorithm to use for JWT signature verification."
+ jwtSignatureAlgorithm: "The algorithm to use for JWT signature verification.",
+ mfaClaimName: "The ID token claim that lists the authentication methods the user completed. Defaults to amr.",
+ mfaAmrValues: "Additional MFA claim values, besides 'mfa', that prove the identity provider completed MFA."
},
CREATE_CONFIG: {
organizationId: "The ID of the organization to create the OIDC config for.",
@@ -4226,7 +4228,9 @@ export const OidcSSo = {
isActive: "Whether to enable or disable this OIDC configuration.",
manageGroupMemberships:
"Whether to manage group memberships for the OIDC configuration. If enabled, users will automatically be assigned groups when they sign in, based on which groups they are a member of in the OIDC provider.",
- jwtSignatureAlgorithm: "The algorithm to use for JWT signature verification."
+ jwtSignatureAlgorithm: "The algorithm to use for JWT signature verification.",
+ mfaClaimName: "The ID token claim that lists the authentication methods the user completed. Defaults to amr.",
+ mfaAmrValues: "Additional MFA claim values, besides 'mfa', that prove the identity provider completed MFA."
}
};
@@ -4243,7 +4247,11 @@ export const SamlSso = {
issuer: "The SAML provider issuer URL or entity ID.",
cert: "The certificate to use for SAML authentication.",
enableGroupSync:
- "Whether to enable automatic synchronization of group memberships from the SAML provider to Infisical groups."
+ "Whether to enable automatic synchronization of group memberships from the SAML provider to Infisical groups.",
+ mfaSignalAttribute:
+ "The SAML attribute that lists the authentication methods the user completed, such as an Okta attribute with value session.amr. Defaults to amr.",
+ mfaAuthnContexts:
+ "Additional AuthnContextClassRef values, besides the built-in two-factor classes, that prove the identity provider completed MFA."
},
CREATE_CONFIG: {
organizationId: "The ID of the organization to create the SAML config for.",
@@ -4254,7 +4262,11 @@ export const SamlSso = {
issuer: "The SAML provider issuer URL or entity ID.",
cert: "The certificate to use for SAML authentication.",
enableGroupSync:
- "Whether to enable automatic synchronization of group memberships from the SAML provider to Infisical groups."
+ "Whether to enable automatic synchronization of group memberships from the SAML provider to Infisical groups.",
+ mfaSignalAttribute:
+ "The SAML attribute that lists the authentication methods the user completed, such as an Okta attribute with value session.amr. Defaults to amr.",
+ mfaAuthnContexts:
+ "Additional AuthnContextClassRef values, besides the built-in two-factor classes, that prove the identity provider completed MFA."
},
ACS: {
samlConfigId: "The ID of the SAML configuration the response is for.",
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index d39caaebaa..476540ed9d 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -40,6 +40,7 @@ export type TAuthMode =
authMethod: AuthMethod;
isMfaVerified?: boolean;
mfaMethod?: MfaMethod;
+ idpMfaVerified?: boolean;
oauthClientId?: string;
token: AuthModeJwtTokenPayload;
}
@@ -333,7 +334,8 @@ export const injectIdentity = fp(
authMethod: token.authMethod,
isMfaVerified: token.isMfaVerified,
token,
- mfaMethod: token.mfaMethod
+ mfaMethod: token.mfaMethod,
+ idpMfaVerified: token.idpMfaVerified
};
fireIdentifyForUser(user);
break;
diff --git a/backend/src/server/routes/sanitizedSchema/directory-config.ts b/backend/src/server/routes/sanitizedSchema/directory-config.ts
index 61be4d9cf6..d27569cd26 100644
--- a/backend/src/server/routes/sanitizedSchema/directory-config.ts
+++ b/backend/src/server/routes/sanitizedSchema/directory-config.ts
@@ -7,7 +7,9 @@ export const SanitizedSamlConfigSchema = SamlConfigsSchema.pick({
lastUsed: true,
createdAt: true,
updatedAt: true,
- authProvider: true
+ authProvider: true,
+ mfaSignalAttribute: true,
+ mfaAuthnContexts: true
});
export const SanitizedLdapConfigSchema = LdapConfigsSchema.pick({
diff --git a/backend/src/server/routes/v1/auth-router.ts b/backend/src/server/routes/v1/auth-router.ts
index 6a29ea1c9e..999ffc3e3f 100644
--- a/backend/src/server/routes/v1/auth-router.ts
+++ b/backend/src/server/routes/v1/auth-router.ts
@@ -154,7 +154,8 @@ export const registerAuthRoutes = async (server: FastifyZodProvider) => {
organizationId: decodedToken.organizationId,
...(decodedToken.subOrganizationId && { subOrganizationId: decodedToken.subOrganizationId }),
isMfaVerified: decodedToken.isMfaVerified,
- mfaMethod: decodedToken.mfaMethod
+ mfaMethod: decodedToken.mfaMethod,
+ idpMfaVerified: decodedToken.idpMfaVerified
},
appCfg.AUTH_SECRET,
{ expiresIn }
diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.ts
index 371c1ae3b1..d0fb93a268 100644
--- a/backend/src/server/routes/v1/organization-router.ts
+++ b/backend/src/server/routes/v1/organization-router.ts
@@ -24,7 +24,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { GenericResourceNameSchema, slugSchema } from "@app/server/lib/schemas";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
-import { ActorType, AuthMode, MfaMethod } from "@app/services/auth/auth-type";
+import { ActorType, AuthMode, MfaMethod, SsoMfaTrust } from "@app/services/auth/auth-type";
import { OrgWithSubOrgsSchema, sanitizedOrganizationSchema } from "@app/services/org/org-schema";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
@@ -531,6 +531,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
defaultMembershipRoleSlug: slugSchema({ max: 64, field: "Default Membership Role" }).optional(),
enforceMfa: z.boolean().optional(),
selectedMfaMethod: z.nativeEnum(MfaMethod).optional(),
+ ssoMfaTrust: z.nativeEnum(SsoMfaTrust).optional(),
allowSecretSharingOutsideOrganization: z.boolean().optional(),
bypassOrgAuthEnabled: z.boolean().optional(),
userTokenExpiration: z
diff --git a/backend/src/server/routes/v3/login-router.ts b/backend/src/server/routes/v3/login-router.ts
index 84131d92c3..641c53a439 100644
--- a/backend/src/server/routes/v3/login-router.ts
+++ b/backend/src/server/routes/v3/login-router.ts
@@ -76,9 +76,10 @@ export const registerLoginRouter = async (server: FastifyZodProvider) => {
ipAddress: req.realIp,
userId: req.auth.userId,
userAuthMethod: req.auth.authMethod,
- actorOrgId: req.auth.orgId,
+ actorRootOrgId: req.auth.rootOrgId,
isMfaVerified: req.auth.isMfaVerified,
- mfaMethod: req.auth.mfaMethod
+ mfaMethod: req.auth.mfaMethod,
+ idpMfaVerified: req.auth.idpMfaVerified
});
if (tokens.isMfaEnabled) {
diff --git a/backend/src/services/auth-token/auth-token-service.ts b/backend/src/services/auth-token/auth-token-service.ts
index 6d44021890..60afc10768 100644
--- a/backend/src/services/auth-token/auth-token-service.ts
+++ b/backend/src/services/auth-token/auth-token-service.ts
@@ -349,7 +349,8 @@ export const tokenServiceFactory = ({ tokenDAL, userDAL, orgDAL, keyStore }: TAu
organizationId: decodedToken.organizationId,
...(decodedToken.subOrganizationId && { subOrganizationId: decodedToken.subOrganizationId }),
isMfaVerified: decodedToken.isMfaVerified,
- mfaMethod: decodedToken.mfaMethod
+ mfaMethod: decodedToken.mfaMethod,
+ idpMfaVerified: decodedToken.idpMfaVerified
},
appCfg.AUTH_SECRET,
{ expiresIn: refreshTokenExpiresIn }
diff --git a/backend/src/services/auth/auth-fns.test.ts b/backend/src/services/auth/auth-fns.test.ts
index 5ffdd12429..979f6ada86 100644
--- a/backend/src/services/auth/auth-fns.test.ts
+++ b/backend/src/services/auth/auth-fns.test.ts
@@ -1,11 +1,12 @@
import { LoginMethod } from "../super-admin/super-admin-types";
import {
assertOAuthLoginMethodEnabled,
+ isIdpMfaTrusted,
isMfaProofAccepted,
isOAuthLoginMethodDisabled,
RECOVERY_CODE_MFA_ASSURANCE
} from "./auth-fns";
-import { AuthMethod, MfaMethod } from "./auth-type";
+import { AuthMethod, MfaMethod, SsoMfaTrust } from "./auth-type";
describe("OAuth login method policy", () => {
test.each([
@@ -62,3 +63,30 @@ describe("isMfaProofAccepted", () => {
expect(isMfaProofAccepted("1", [MfaMethod.EMAIL])).toBe(false);
});
});
+
+describe("isIdpMfaTrusted", () => {
+ test.each([AuthMethod.OKTA_SAML, AuthMethod.AZURE_SAML, AuthMethod.OIDC] as const)(
+ "trusts a signalled %s login when the org trusts the signal",
+ (authMethod) => {
+ expect(isIdpMfaTrusted({ ssoMfaTrust: SsoMfaTrust.Signal, authMethod, idpMfaVerified: true })).toBe(true);
+ }
+ );
+
+ test("never trusts a login that carried no signal", () => {
+ expect(isIdpMfaTrusted({ ssoMfaTrust: SsoMfaTrust.Signal, authMethod: AuthMethod.OKTA_SAML })).toBe(false);
+ expect(
+ isIdpMfaTrusted({ ssoMfaTrust: SsoMfaTrust.Signal, authMethod: AuthMethod.OIDC, idpMfaVerified: false })
+ ).toBe(false);
+ });
+
+ test.each([AuthMethod.EMAIL, AuthMethod.GOOGLE, AuthMethod.GITHUB, AuthMethod.LDAP] as const)(
+ "never trusts a %s login, so break-glass accounts keep the Infisical challenge",
+ (authMethod) => {
+ expect(isIdpMfaTrusted({ ssoMfaTrust: SsoMfaTrust.Signal, authMethod, idpMfaVerified: true })).toBe(false);
+ }
+ );
+
+ test.each([SsoMfaTrust.None, undefined, null, "delegate"])("ignores the signal when the setting is %s", (mode) => {
+ expect(isIdpMfaTrusted({ ssoMfaTrust: mode, authMethod: AuthMethod.OIDC, idpMfaVerified: true })).toBe(false);
+ });
+});
diff --git a/backend/src/services/auth/auth-fns.ts b/backend/src/services/auth/auth-fns.ts
index cf03ac1f7b..f4315e7143 100644
--- a/backend/src/services/auth/auth-fns.ts
+++ b/backend/src/services/auth/auth-fns.ts
@@ -1,3 +1,4 @@
+import { isAuthMethodSaml } from "@app/ee/services/permission/permission-fns";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto";
import { BadRequestError, ForbiddenRequestError, UnauthorizedError } from "@app/lib/errors";
@@ -8,7 +9,8 @@ import {
AuthModeAccountRecoveryTokenPayload,
AuthModeSignUpTokenPayload,
AuthTokenType,
- MfaMethod
+ MfaMethod,
+ SsoMfaTrust
} from "./auth-type";
const oauthLoginMethods = {
@@ -71,6 +73,21 @@ export const getRequiredMfaMethod = (
return { isMfaRequired, requiredMfaMethod };
};
+// Only SAML and OIDC carry a signed IdP signal. Password, Google and LDAP never qualify, so break-glass
+// accounts always get the Infisical challenge.
+export const isIdpMfaTrusted = ({
+ ssoMfaTrust,
+ authMethod,
+ idpMfaVerified
+}: {
+ ssoMfaTrust?: string | null;
+ authMethod: AuthMethod;
+ idpMfaVerified?: boolean;
+}): boolean => {
+ if (!isAuthMethodSaml(authMethod) && authMethod !== AuthMethod.OIDC) return false;
+ return ssoMfaTrust === SsoMfaTrust.Signal && Boolean(idpMfaVerified);
+};
+
export const RECOVERY_CODE_MFA_ASSURANCE = "recovery-code";
export type TMfaAssurance = MfaMethod | typeof RECOVERY_CODE_MFA_ASSURANCE;
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index fdf03b7530..97bc6aa7b0 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -57,6 +57,7 @@ import {
assertOAuthLoginMethodEnabled,
enforceUserLockStatus,
getRequiredMfaMethod,
+ isIdpMfaTrusted,
isOAuthLoginMethodDisabled,
OAuthAuthMethod,
RECOVERY_CODE_MFA_ASSURANCE
@@ -188,13 +189,15 @@ export const authLoginServiceFactory = ({
email,
authMethod,
organizationId,
- requiredMfaMethod
+ requiredMfaMethod,
+ idpMfaVerified
}: {
userId: string;
email?: string | null;
authMethod: AuthMethod;
organizationId?: string;
requiredMfaMethod: MfaMethod;
+ idpMfaVerified?: boolean;
}) => {
const appCfg = getConfig();
@@ -205,7 +208,8 @@ export const authLoginServiceFactory = ({
userId,
organizationId,
email,
- requiredMfaMethod
+ requiredMfaMethod,
+ idpMfaVerified
},
appCfg.AUTH_SECRET,
{ expiresIn: appCfg.JWT_MFA_LIFETIME }
@@ -233,7 +237,8 @@ export const authLoginServiceFactory = ({
subOrganizationId,
authMethod,
isMfaVerified,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified
}: {
userId: string;
ip: string;
@@ -243,6 +248,7 @@ export const authLoginServiceFactory = ({
authMethod: AuthMethod;
isMfaVerified?: boolean;
mfaMethod?: MfaMethod;
+ idpMfaVerified?: boolean;
},
tx?: Knex
) => {
@@ -290,7 +296,8 @@ export const authLoginServiceFactory = ({
organizationId,
subOrganizationId,
isMfaVerified,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified
},
cfg.AUTH_SECRET,
{ expiresIn: tokenSessionExpiresIn }
@@ -306,7 +313,8 @@ export const authLoginServiceFactory = ({
organizationId,
subOrganizationId,
isMfaVerified,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified
},
cfg.AUTH_SECRET,
{ expiresIn: refreshTokenExpiresIn }
@@ -323,7 +331,8 @@ export const authLoginServiceFactory = ({
ip,
userAgent,
organizationId,
- callbackPort
+ callbackPort,
+ idpMfa
}: TProcessProviderCallbackDTO): Promise<TProviderAuthCallback> => {
const appCfg = getConfig();
@@ -353,7 +362,8 @@ export const authLoginServiceFactory = ({
userId: user.id,
ip,
userAgent,
- authMethod
+ authMethod,
+ idpMfaVerified: idpMfa?.verified || undefined
});
if (organizationId) {
@@ -366,6 +376,31 @@ export const authLoginServiceFactory = ({
},
{ status: OrgMembershipStatus.Accepted }
);
+
+ // The session token only carries the verdict, so the raw IdP values are recorded here for admins.
+ await auditLogService.createAuditLog({
+ orgId: organizationId,
+ ipAddress: ip,
+ userAgent,
+ userAgentType: getUserAgentType(userAgent),
+ actor: {
+ type: ActorType.USER,
+ metadata: {
+ email: user.email,
+ userId: user.id,
+ username: user.username ?? user.email ?? "",
+ authMethod
+ }
+ },
+ event: {
+ type: EventType.USER_LOGIN,
+ metadata: {
+ organizationId,
+ authProvider: authMethod,
+ ...(idpMfa && { idpMfa })
+ }
+ }
+ });
}
return { result: ProviderAuthResult.SESSION, tokens, callbackPort } as const;
@@ -739,7 +774,8 @@ export const authLoginServiceFactory = ({
organizationId: orgId,
authMethod: decodedToken.authMethod,
isMfaVerified: true,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified: decodedToken.idpMfaVerified
});
// Open the grace window for THIS session only (the one that just proved MFA), so
@@ -1153,18 +1189,20 @@ export const authLoginServiceFactory = ({
organizationId,
userId,
userAuthMethod,
- actorOrgId,
+ actorRootOrgId,
isMfaVerified,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified
}: {
userAgent: string | undefined;
ipAddress: string;
organizationId: string;
userId: string;
userAuthMethod: AuthMethod;
- actorOrgId?: string;
+ actorRootOrgId?: string;
isMfaVerified?: boolean;
mfaMethod?: MfaMethod;
+ idpMfaVerified?: boolean;
}) => {
const cfg = getConfig();
if (!userAgent) throw new UnauthorizedError({ name: "User-Agent header is required" });
@@ -1288,12 +1326,20 @@ export const authLoginServiceFactory = ({
}
const { isMfaRequired, requiredMfaMethod } = getRequiredMfaMethod(rootOrg, user);
- // Check if organization has changed
- const hasOrganizationChanged = actorOrgId ? actorOrgId !== rootOrg.id : false;
- // Check if MFA method has changed
+ // The MFA policy belongs to the root org, so switching between it and its sub-orgs is not a change.
+ const hasOrganizationChanged = actorRootOrgId ? actorRootOrgId !== rootOrg.id : false;
const hasMfaMethodChanged = mfaMethod !== requiredMfaMethod;
- // Trigger MFA if required and either not verified or something changed
- const shouldTriggerMfa = isMfaRequired && (!isMfaVerified || hasMfaMethodChanged || hasOrganizationChanged);
+ // Checked on every selection so turning the trust off applies at the next switch. It only waives the
+ // org's enforcement, never MFA a user turned on for their own account.
+ const isMfaSatisfiedByIdp =
+ Boolean(rootOrg.enforceMfa) &&
+ isIdpMfaTrusted({
+ ssoMfaTrust: rootOrg.ssoMfaTrust,
+ authMethod: userAuthMethod,
+ idpMfaVerified
+ });
+ const shouldTriggerMfa =
+ isMfaRequired && !isMfaSatisfiedByIdp && (!isMfaVerified || hasMfaMethodChanged || hasOrganizationChanged);
if (shouldTriggerMfa) {
enforceUserLockStatus(Boolean(user.isLocked), user.temporaryLockDateEnd);
@@ -1303,7 +1349,8 @@ export const authLoginServiceFactory = ({
email: user.email,
authMethod: userAuthMethod,
requiredMfaMethod,
- organizationId: rootOrg.id
+ organizationId: rootOrg.id,
+ idpMfaVerified
});
return { isMfaEnabled: true, mfa: mfaToken, mfaMethod: requiredMfaMethod } as const;
@@ -1319,9 +1366,14 @@ export const authLoginServiceFactory = ({
organizationId: isSubOrganization ? rootOrg.id : organizationId,
subOrganizationId: isSubOrganization ? organizationId : undefined,
isMfaVerified,
- mfaMethod
+ mfaMethod,
+ idpMfaVerified
});
+ let mfaSatisfiedBy: "not-required" | "infisical" | "idp" = "infisical";
+ if (!isMfaRequired) mfaSatisfiedBy = "not-required";
+ else if (isMfaSatisfiedByIdp) mfaSatisfiedBy = "idp";
+
// In the event of this being a break-glass request (non-saml / non-oidc / non-google, when any is enforced)
const isAuthEnforcedBypass =
rootOrg.authEnforced &&
@@ -1412,14 +1464,16 @@ export const authLoginServiceFactory = ({
metadata: {
organizationId,
organizationName: selectedOrg.name,
- rootOrganizationId: selectedOrg.rootOrgId || ""
+ rootOrganizationId: selectedOrg.rootOrgId || "",
+ mfaSatisfiedBy
}
}
: {
type: EventType.SELECT_ORGANIZATION,
metadata: {
organizationId,
- organizationName: selectedOrg.name
+ organizationName: selectedOrg.name,
+ mfaSatisfiedBy
}
}
});
diff --git a/backend/src/services/auth/auth-login-type.ts b/backend/src/services/auth/auth-login-type.ts
index 7cae51b4d5..ffc2a0133c 100644
--- a/backend/src/services/auth/auth-login-type.ts
+++ b/backend/src/services/auth/auth-login-type.ts
@@ -1,4 +1,5 @@
import { AuthMethod, MfaMethod, ProviderAuthResult } from "./auth-type";
+import { TIdpMfaSignal } from "./idp-mfa-signal";
export type TLoginGenServerPublicKeyDTO = {
email: string;
@@ -51,6 +52,7 @@ export type TProcessProviderCallbackDTO = {
firstName?: string | null;
lastName?: string | null;
isLocked?: boolean | null;
+ username?: string | null;
};
authMethod: AuthMethod;
isEmailVerified: boolean;
@@ -59,6 +61,7 @@ export type TProcessProviderCallbackDTO = {
userAgent: string;
organizationId?: string;
callbackPort?: number;
+ idpMfa?: TIdpMfaSignal;
};
export type TProviderAuthResult =
diff --git a/backend/src/services/auth/auth-type.ts b/backend/src/services/auth/auth-type.ts
index 826a69c300..d5ced74aa1 100644
--- a/backend/src/services/auth/auth-type.ts
+++ b/backend/src/services/auth/auth-type.ts
@@ -13,6 +13,11 @@ export enum AuthMethod {
OIDC = "oidc"
}
+export enum SsoMfaTrust {
+ None = "none",
+ Signal = "signal"
+}
+
export enum AuthTokenType {
ACCESS_TOKEN = "accessToken",
REFRESH_TOKEN = "refreshToken",
@@ -113,6 +118,7 @@ export type AuthModeJwtTokenPayload = {
subOrganizationId?: string;
isMfaVerified?: boolean;
mfaMethod?: MfaMethod;
+ idpMfaVerified?: boolean;
// Present only on delegated OAuth 2.0 access tokens. Its presence marks the token as
// AuthMode.OAUTH so the default JWT middleware will not accept it as a first-party session.
oauthClientId?: string;
@@ -130,6 +136,7 @@ export type AuthModeMfaJwtTokenPayload = {
userId: string;
organizationId?: string;
requiredMfaMethod: MfaMethod;
+ idpMfaVerified?: boolean;
};
export type AuthModeRefreshJwtTokenPayload = {
@@ -143,6 +150,7 @@ export type AuthModeRefreshJwtTokenPayload = {
subOrganizationId?: string;
isMfaVerified?: boolean;
mfaMethod?: MfaMethod;
+ idpMfaVerified?: boolean;
oauthClientId?: string;
scopes?: string[];
};
diff --git a/backend/src/services/auth/idp-mfa-signal.test.ts b/backend/src/services/auth/idp-mfa-signal.test.ts
new file mode 100644
index 0000000000..c9dffe164c
--- /dev/null
+++ b/backend/src/services/auth/idp-mfa-signal.test.ts
@@ -0,0 +1,150 @@
+import { extractSamlAuthnContextClassRefs, matchIdpMfaSignal } from "./idp-mfa-signal";
+
+const MULTIPLEAUTHN = "http://schemas.microsoft.com/claims/multipleauthn";
+const AUTHN_METHODS_REFERENCES = "http://schemas.microsoft.com/claims/authnmethodsreferences";
+
+const oidc = (claims: Record<string, unknown>, config?: { mfaClaimName?: string; mfaAmrValues?: string[] }) =>
+ matchIdpMfaSignal({ kind: "oidc", claims, config });
+
+describe("matchIdpMfaSignal for OIDC", () => {
+ test.each([
+ ["Okta with a second factor", ["pwd", "mfa", "otp"]],
+ ["Entra ID Authenticator push", ["pwd", "rsa", "mfa"]],
+ ["Auth0 after an MFA challenge", ["mfa"]],
+ ["Google with a hardware key", ["pwd", "hwk", "mfa"]]
+ ])("accepts %s", (_, amr) => {
+ expect(oidc({ sub: "u1", amr })).toEqual({ verified: true, evidence: ["mfa"] });
+ });
+
+ test.each([
+ ["password only", ["pwd"]],
+ ["federated upstream IdP", ["fed", "pwd"]],
+ ["missing claim", undefined],
+ ["claim of the wrong type", 42],
+ ["mfa embedded in another word", ["pwd", "nomfa"]]
+ ])("rejects %s", (_, amr) => {
+ expect(oidc({ sub: "u1", amr })).toEqual({ verified: false, evidence: [] });
+ });
+
+ test("ignores case and surrounding whitespace", () => {
+ expect(oidc({ amr: [" MFA "] })).toEqual({ verified: true, evidence: ["MFA"] });
+ });
+
+ test("reads amr when the configuration carries no claim name", () => {
+ expect(oidc({ amr: ["mfa"] }, { mfaClaimName: "" }).verified).toBe(true);
+ expect(oidc({ amr: ["mfa"] }, undefined).verified).toBe(true);
+ });
+
+ test("reads the configured claim instead of amr", () => {
+ const config = { mfaClaimName: "authentication_methods" };
+ expect(oidc({ amr: ["mfa"], authentication_methods: ["pwd"] }, config).verified).toBe(false);
+ expect(oidc({ amr: ["pwd"], authentication_methods: ["mfa"] }, config)).toEqual({
+ verified: true,
+ evidence: ["mfa"]
+ });
+ });
+
+ test("accepts extra values from the configuration on top of the defaults", () => {
+ const config = { mfaAmrValues: ["otp"] };
+ expect(oidc({ amr: ["pwd", "otp"] }, config)).toEqual({ verified: true, evidence: ["otp"] });
+ expect(oidc({ amr: ["mfa"] }, config).verified).toBe(true);
+ });
+});
+
+const saml = (
+ authnContextClassRefs: string[],
+ attributes?: Record<string, unknown>,
+ config?: { mfaSignalAttribute?: string; mfaAuthnContexts?: string[] }
+) => matchIdpMfaSignal({ kind: "saml", authnContextClassRefs, attributes, config });
+
+describe("matchIdpMfaSignal for SAML", () => {
+ test.each([
+ ["Entra ID Authenticator", "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract"],
+ ["Entra ID TOTP", "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken"],
+ ["Entra ID passkey", "urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI"],
+ ["REFEDS MFA profile", "https://refeds.org/profile/mfa"],
+ ["Entra ID multipleauthn context", MULTIPLEAUTHN]
+ ])("accepts the %s context class", (_, classRef) => {
+ expect(saml([classRef])).toEqual({ verified: true, evidence: [classRef] });
+ });
+
+ test.each([
+ ["PasswordProtectedTransport (Okta default)", "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"],
+ ["MobileTwoFactorUnregistered", "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorUnregistered"],
+ ["Password", "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"],
+ ["unspecified", "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"]
+ ])("rejects the single-factor %s context class", (_, classRef) => {
+ expect(saml([classRef]).verified).toBe(false);
+ });
+
+ test("accepts an Okta amr attribute statement built from session.amr", () => {
+ const passwordOnly = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";
+ expect(saml([passwordOnly], { amr: ["pwd", "mfa", "swk"] })).toEqual({ verified: true, evidence: ["amr=mfa"] });
+ });
+
+ test("reads a single-valued attribute as a string, whatever its case", () => {
+ expect(saml([], { AMR: "mfa" })).toEqual({ verified: true, evidence: ["AMR=mfa"] });
+ });
+
+ test("reads the Entra ID authnmethodsreferences attribute when the configuration names it", () => {
+ const attributes = {
+ [AUTHN_METHODS_REFERENCES]: [
+ "http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password",
+ MULTIPLEAUTHN
+ ]
+ };
+ const passwordClass = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password";
+ expect(saml([passwordClass], attributes).verified).toBe(false);
+ expect(saml([passwordClass], attributes, { mfaSignalAttribute: AUTHN_METHODS_REFERENCES })).toEqual({
+ verified: true,
+ evidence: [`${AUTHN_METHODS_REFERENCES}=${MULTIPLEAUTHN}`]
+ });
+ });
+
+ test("reads only the configured attribute, not amr, once a name is set", () => {
+ const attributes = { amr: ["mfa"], authMethods: ["pwd"] };
+ expect(saml([], attributes, { mfaSignalAttribute: "authMethods" }).verified).toBe(false);
+ });
+
+ test("accepts extra context classes from the configuration on top of the defaults", () => {
+ const custom = "urn:example:ac:classes:HardwareToken";
+ expect(saml([custom]).verified).toBe(false);
+ expect(saml([custom], undefined, { mfaAuthnContexts: [custom] })).toEqual({ verified: true, evidence: [custom] });
+ });
+
+ test("rejects a password-only assertion with unrelated attributes", () => {
+ const passwordOnly = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";
+ expect(saml([passwordOnly], { email: "[email protected]", groups: ["admins"], amr: ["pwd"] })).toEqual({
+ verified: false,
+ evidence: []
+ });
+ });
+});
+
+describe("extractSamlAuthnContextClassRefs", () => {
+ const classRef = "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken";
+
+ test("walks the xml2js shape node-saml produces for an assertion", () => {
+ const parsed = {
+ Assertion: {
+ $: { ID: "_abc" },
+ AuthnStatement: [
+ { $: { AuthnInstant: "2026-10-29T00:00:00Z" }, AuthnContext: [{ AuthnContextClassRef: [{ _: classRef }] }] }
+ ]
+ }
+ };
+ expect(extractSamlAuthnContextClassRefs(parsed)).toEqual([classRef]);
+ });
+
+ test("walks an assertion wrapped in a response", () => {
+ const parsed = {
+ Response: { Assertion: [{ AuthnStatement: [{ AuthnContext: [{ AuthnContextClassRef: [classRef] }] }] }] }
+ };
+ expect(extractSamlAuthnContextClassRefs(parsed)).toEqual([classRef]);
+ });
+
+ test("returns nothing for an assertion without an authentication statement", () => {
+ expect(extractSamlAuthnContextClassRefs({ Assertion: { Subject: [{}] } })).toEqual([]);
+ expect(extractSamlAuthnContextClassRefs(undefined)).toEqual([]);
+ });
+});
diff --git a/backend/src/services/auth/idp-mfa-signal.ts b/backend/src/services/auth/idp-mfa-signal.ts
new file mode 100644
index 0000000000..53f4c309d1
--- /dev/null
+++ b/backend/src/services/auth/idp-mfa-signal.ts
@@ -0,0 +1,124 @@
+// "amr" is the OIDC Core claim name. SAML has no standard attribute name, so the Okta convention is the default.
+export const DEFAULT_MFA_CLAIM_NAME = "amr";
+
+// RFC 8176 value for a completed multi-factor login; Okta, Entra ID, Auth0, Google and Duo all emit it.
+export const DEFAULT_OIDC_MFA_CLAIM_VALUES = ["mfa"];
+
+// Two-factor SAML classes, the REFEDS MFA profile and Entra ID's satisfied-MFA class. Single-factor classes
+// such as PasswordProtectedTransport and MobileTwoFactorUnregistered are deliberately absent.
+export const DEFAULT_SAML_MFA_AUTHN_CONTEXTS = [
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract",
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken",
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:Smartcard",
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI",
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI",
+ "https://refeds.org/profile/mfa",
+ "http://schemas.microsoft.com/claims/multipleauthn"
+];
+
+// The RFC 8176 value, plus the URI Entra ID uses in its authnmethodsreferences claim.
+const SAML_MFA_ATTRIBUTE_VALUES = ["mfa", "http://schemas.microsoft.com/claims/multipleauthn"];
+
+// The assertion is signed, but a misbehaving IdP could still send an absurd number of values.
+const MAX_SIGNAL_VALUES = 50;
+const MAX_SIGNAL_VALUE_LENGTH = 512;
+
+export type TIdpMfaSignal = {
+ verified: boolean;
+ evidence: string[];
+};
+
+export type TSamlMfaSignalConfig = {
+ mfaSignalAttribute?: string | null;
+ mfaAuthnContexts?: string[] | null;
+};
+
+export type TOidcMfaSignalConfig = {
+ mfaClaimName?: string | null;
+ mfaAmrValues?: string[] | null;
+};
+
+export type TIdpMfaSignalInput =
+ | {
+ kind: "saml";
+ authnContextClassRefs: string[];
+ attributes?: Record<string, unknown> | null;
+ config?: TSamlMfaSignalConfig | null;
+ }
+ | {
+ kind: "oidc";
+ claims: Record<string, unknown>;
+ config?: TOidcMfaSignalConfig | null;
+ };
+
+const toStringList = (value: unknown): string[] => {
+ const raw = Array.isArray(value) ? value : [value];
+ return raw
+ .filter((item): item is string => typeof item === "string")
+ .map((item) => item.trim())
+ .filter((item) => item.length > 0 && item.length <= MAX_SIGNAL_VALUE_LENGTH)
+ .slice(0, MAX_SIGNAL_VALUES);
+};
+
+const matchingValues = (values: string[], accepted: string[]) => {
+ const acceptedSet = new Set(accepted.map((item) => item.trim().toLowerCase()));
+ return values.filter((value) => acceptedSet.has(value.toLowerCase()));
+};
+
+const findKey = (record: Record<string, unknown>, name: string) => {
+ const wanted = name.trim().toLowerCase();
+ return Object.keys(record).find((key) => key.toLowerCase() === wanted);
+};
+
+export const matchIdpMfaSignal = (input: TIdpMfaSignalInput): TIdpMfaSignal => {
+ if (input.kind === "oidc") {
+ const claimName = input.config?.mfaClaimName?.trim() || DEFAULT_MFA_CLAIM_NAME;
+ const claimKey = findKey(input.claims, claimName);
+ const accepted = [...DEFAULT_OIDC_MFA_CLAIM_VALUES, ...(input.config?.mfaAmrValues ?? [])];
+ const evidence = claimKey ? matchingValues(toStringList(input.claims[claimKey]), accepted) : [];
+ return { verified: evidence.length > 0, evidence };
+ }
+
+ const acceptedContexts = [...DEFAULT_SAML_MFA_AUTHN_CONTEXTS, ...(input.config?.mfaAuthnContexts ?? [])];
+ const evidence = matchingValues(toStringList(input.authnContextClassRefs), acceptedContexts);
+
+ const attributes = input.attributes ?? {};
+ const attributeName = input.config?.mfaSignalAttribute?.trim() || DEFAULT_MFA_CLAIM_NAME;
+ const attributeKey = findKey(attributes, attributeName);
+ if (attributeKey) {
+ matchingValues(toStringList(attributes[attributeKey]), SAML_MFA_ATTRIBUTE_VALUES).forEach((value) => {
+ evidence.push(`${attributeKey}=${value}`);
+ });
+ }
+
+ return { verified: evidence.length > 0, evidence };
+};
+
+// node-saml parses with xml2js explicitArray and explicitCharkey: every child is an array, a text node is
+// { _: "value" }, and the root is either the Assertion or a Response wrapping one.
+const textOf = (node: unknown): string | undefined => {
+ if (typeof node === "string") return node;
+ if (node && typeof node === "object" && "_" in node && typeof (node as { _: unknown })._ === "string") {
+ return (node as { _: string })._;
+ }
+ return undefined;
+};
+
+const children = (node: unknown, name: string): unknown[] => {
+ if (!node || typeof node !== "object") return [];
+ const value = (node as Record<string, unknown>)[name];
+ if (value === undefined || value === null) return [];
+ return Array.isArray(value) ? value : [value];
+};
+
+export const extractSamlAuthnContextClassRefs = (parsedAssertion: unknown): string[] => {
+ const root =
+ children(parsedAssertion, "Assertion")[0] ??
+ children(children(parsedAssertion, "Response")[0], "Assertion")[0] ??
+ parsedAssertion;
+ return children(root, "AuthnStatement")
+ .flatMap((statement) => children(statement, "AuthnContext"))
+ .flatMap((context) => children(context, "AuthnContextClassRef"))
+ .map(textOf)
+ .filter((value): value is string => Boolean(value));
+};
diff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.ts
index 2bf8655223..77b6df5973 100644
--- a/backend/src/services/org/org-schema.ts
+++ b/backend/src/services/org/org-schema.ts
@@ -16,6 +16,7 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
defaultMembershipRole: true,
enforceMfa: true,
selectedMfaMethod: true,
+ ssoMfaTrust: true,
allowSecretSharingOutsideOrganization: true,
shouldUseNewPrivilegeSystem: true,
privilegeUpgradeInitiatedByUsername: true,
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index b02cdfae4c..17f8d7afb1 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -62,7 +62,14 @@ import { TUserAliasDALFactory } from "@app/services/user-alias/user-alias-dal";
import { TAuthTokenServiceFactory } from "../auth-token/auth-token-service";
import { TokenType } from "../auth-token/auth-token-types";
import { TAuthLoginFactory } from "../auth/auth-login-service";
-import { ActorAuthMethod, ActorType, AuthMethod, AuthModeJwtTokenPayload, AuthTokenType } from "../auth/auth-type";
+import {
+ ActorAuthMethod,
+ ActorType,
+ AuthMethod,
+ AuthModeJwtTokenPayload,
+ AuthTokenType,
+ SsoMfaTrust
+} from "../auth/auth-type";
import { bootstrapCertManagerProject } from "../cert-manager-instance/cert-manager-project-bootstrap";
import { TCertificatePolicyDALFactory } from "../certificate-policy/certificate-policy-dal";
import { TEventEmitter } from "../event-outbox/event-outbox-types";
@@ -503,6 +510,7 @@ export const orgServiceFactory = ({
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
+ ssoMfaTrust,
allowSecretSharingOutsideOrganization,
bypassOrgAuthEnabled,
userTokenExpiration,
@@ -581,6 +589,22 @@ export const orgServiceFactory = ({
}
}
+ if (ssoMfaTrust !== undefined && ssoMfaTrust !== SsoMfaTrust.None) {
+ if (!plan.enforceMfa) {
+ throw new BadRequestError({
+ message:
+ "Failed to update MFA for SSO logins due to plan restriction. Upgrade plan to trust identity provider MFA."
+ });
+ }
+
+ if (!currentOrg.orgAuthMethod) {
+ throw new BadRequestError({
+ message:
+ "Trusting the identity provider's MFA signal requires an active SAML or OIDC SSO configuration. Set up SSO first."
+ });
+ }
+ }
+
if (authEnforced !== undefined) {
if (!plan?.samlSSO && !plan.oidcSSO)
throw new BadRequestError({
@@ -718,6 +742,7 @@ export const orgServiceFactory = ({
defaultMembershipRole,
enforceMfa,
selectedMfaMethod,
+ ssoMfaTrust,
allowSecretSharingOutsideOrganization,
bypassOrgAuthEnabled,
userTokenExpiration,
diff --git a/backend/src/services/org/org-types.ts b/backend/src/services/org/org-types.ts
index beef563466..259ead4f91 100644
--- a/backend/src/services/org/org-types.ts
+++ b/backend/src/services/org/org-types.ts
@@ -2,7 +2,7 @@ import { z } from "zod";
import { TOrgPermission } from "@app/lib/types";
-import { ActorAuthMethod, ActorType, MfaMethod } from "../auth/auth-type";
+import { ActorAuthMethod, ActorType, MfaMethod, SsoMfaTrust } from "../auth/auth-type";
import { OrgWithSubOrgsSchema } from "./org-schema";
/** Root org with accessible sub-orgs (basic info only) */
@@ -78,6 +78,7 @@ export type TUpdateOrgDTO = {
defaultMembershipRoleSlug: string;
enforceMfa: boolean;
selectedMfaMethod: MfaMethod;
+ ssoMfaTrust: SsoMfaTrust;
allowSecretSharingOutsideOrganization: boolean;
bypassOrgAuthEnabled: boolean;
userTokenExpiration: string;
diff --git a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt
index 8b2d3a85ee..e44ba78f7a 100644
--- a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt
+++ b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt
@@ -677,6 +677,7 @@ dce
dcr
als
ua
+amr
iss
# --- Surfaced by the code-signing pages ---
diff --git a/docs/documentation/platform/mfa.mdx b/docs/documentation/platform/mfa.mdx
index 43a4030175..939b0ef0af 100644
--- a/docs/documentation/platform/mfa.mdx
+++ b/docs/documentation/platform/mfa.mdx
@@ -17,6 +17,33 @@ If 2-factor authentication is enabled in the Personal settings page, email will
You can use any mobile authenticator app (Authy, Google Authenticator, Duo, etc.) to secure your account. After registration with an authenticator, select **Mobile Authenticator** as your 2FA method.
![Authenticator-based MFA](/images/mfa-authenticator.png)
+## MFA for SSO logins
+
+If your organization enforces MFA and your users sign in through [SAML or OIDC SSO](/documentation/platform/sso/overview), you can let the MFA they completed at your identity provider count, so Infisical doesn't prompt them again. Password and LDAP logins are always prompted, so a break-glass account keeps Infisical MFA. The setting only covers the MFA your organization enforces. A user who turned on MFA for their own account is still prompted.
+
+Infisical trusts a login only if the identity provider's signed response says MFA was completed:
+
+- For OIDC, the ID token's `amr` claim includes `mfa`
+- For SAML, the assertion's authentication context is a two-factor class, such as `MobileTwoFactorContract` or `TimeSyncToken`, or the `amr` attribute statement includes `mfa`
+
+Without a signal, Infisical prompts as usual. The login event in the audit log shows the values the identity provider sent, so you can see why a login was or wasn't prompted.
+
+<Steps>
+ <Step>
+ Configure your identity provider to send the signal. Okta OIDC and Entra ID send it without extra configuration. For Okta SAML, add an attribute statement named `amr` with the value `session.amr`, as described in [Okta SAML](/documentation/platform/sso/okta).
+ </Step>
+ <Step>
+ In your organization, go to **Settings** > **Security** and turn on **Enforce MFA**.
+ </Step>
+ <Step>
+ Go to **Settings** > **Single Sign-On (SSO)** and, in the **Enforcement** card, turn on **Trust IdP MFA**.
+ </Step>
+</Steps>
+
+<Note>
+ If your identity provider lists the methods under another name, change **MFA claim name** in your OIDC configuration or **MFA attribute name** in your SAML configuration. If it uses other values or authentication contexts for MFA, add them under **Additional MFA claim values** or **Additional MFA authentication contexts**.
+</Note>
+
## Entra ID MFA
<Note>
diff --git a/docs/documentation/platform/sso/azure.mdx b/docs/documentation/platform/sso/azure.mdx
index e8b752df51..47d2c20c09 100644
--- a/docs/documentation/platform/sso/azure.mdx
+++ b/docs/documentation/platform/sso/azure.mdx
@@ -63,6 +63,8 @@ description: "Learn how to configure Microsoft Entra ID for Infisical SSO."
![Azure SAML edit attributes and claims 2](../../../images/sso/azure/edit-attributes-claims-2.png)
+ Entra ID reports the sign-in method in the assertion's authentication context, so you can let Infisical trust the MFA your users complete in Entra ID without adding a claim. See [MFA for SSO logins](/documentation/platform/mfa#mfa-for-sso-logins).
+
Back in the **Set up Single Sign-On with SAML** screen, select **Edit** in the **SAML Certificates** section and set the **Signing Option** field to **Sign SAML response and assertion**.
![Azure SAML edit certificate](../../../images/sso/azure/edit-saml-certificate.png)
diff --git a/docs/documentation/platform/sso/okta-oidc.mdx b/docs/documentation/platform/sso/okta-oidc.mdx
index bf96ae0ae9..a7e5487cce 100644
--- a/docs/documentation/platform/sso/okta-oidc.mdx
+++ b/docs/documentation/platform/sso/okta-oidc.mdx
@@ -52,6 +52,8 @@ description: "Learn how to configure Okta OIDC for Infisical SSO."
Infisical takes a user's first name from the `given_name` claim and their last name from `family_name`. Configure `family_name` only if Infisical should store a separate last name. If `given_name` is missing, Infisical falls back to the `name` claim. See [General OIDC](/documentation/platform/sso/general-oidc/overview) for the exact fallback rules.
</Note>
+ Okta includes the `amr` claim in the ID token, so you can let Infisical trust the MFA your users complete in Okta without extra configuration. See [MFA for SSO logins](/documentation/platform/mfa#mfa-for-sso-logins).
+
</Step>
<Step title="Retrieve Identity Provider (IdP) Information from Okta">
After creating the application, you'll be taken to the application's settings page. From the **General** tab, copy the **Client ID** and **Client Secret** values.
diff --git a/docs/documentation/platform/sso/okta.mdx b/docs/documentation/platform/sso/okta.mdx
index 7b806cc2a2..1fc21f2922 100644
--- a/docs/documentation/platform/sso/okta.mdx
+++ b/docs/documentation/platform/sso/okta.mdx
@@ -56,6 +56,8 @@ description: "Learn how to configure Okta SAML 2.0 for Infisical SSO."
![SAML Okta attribute statements](../../../images/sso/okta/attribute-statements.png)
+ If you want Infisical to trust the MFA your users complete in Okta, also add an attribute statement named `amr` with the value `session.amr`. See [MFA for SSO logins](/documentation/platform/mfa#mfa-for-sso-logins).
+
Once configured, select **Next** to proceed to the Feedback screen and select **Finish**.
</Step>
diff --git a/frontend/src/hooks/api/oidcConfig/mutations.tsx b/frontend/src/hooks/api/oidcConfig/mutations.tsx
index c15f8b6b2f..3cc8e7e516 100644
--- a/frontend/src/hooks/api/oidcConfig/mutations.tsx
+++ b/frontend/src/hooks/api/oidcConfig/mutations.tsx
@@ -25,7 +25,9 @@ export const useUpdateOIDCConfig = () => {
isActive,
organizationId,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
}: {
allowedEmailDomains?: string;
issuer?: string;
@@ -41,6 +43,8 @@ export const useUpdateOIDCConfig = () => {
organizationId: string;
manageGroupMemberships?: boolean;
jwtSignatureAlgorithm?: OIDCJWTSignatureAlgorithm;
+ mfaClaimName?: string;
+ mfaAmrValues?: string[] | null;
}) => {
const { data } = await apiRequest.patch("/api/v1/sso/oidc/config", {
issuer,
@@ -56,7 +60,9 @@ export const useUpdateOIDCConfig = () => {
clientSecret,
isActive,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
});
return data;
@@ -87,7 +93,9 @@ export const useCreateOIDCConfig = () => {
isActive,
organizationId,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
}: {
issuer?: string;
configurationType: string;
@@ -103,6 +111,8 @@ export const useCreateOIDCConfig = () => {
allowedEmailDomains?: string;
manageGroupMemberships?: boolean;
jwtSignatureAlgorithm?: OIDCJWTSignatureAlgorithm;
+ mfaClaimName?: string;
+ mfaAmrValues?: string[] | null;
}) => {
const { data } = await apiRequest.post("/api/v1/sso/oidc/config", {
issuer,
@@ -118,7 +128,9 @@ export const useCreateOIDCConfig = () => {
isActive,
organizationId,
manageGroupMemberships,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
});
return data;
diff --git a/frontend/src/hooks/api/oidcConfig/types.ts b/frontend/src/hooks/api/oidcConfig/types.ts
index a814947c7c..5c8e1231f2 100644
--- a/frontend/src/hooks/api/oidcConfig/types.ts
+++ b/frontend/src/hooks/api/oidcConfig/types.ts
@@ -14,6 +14,8 @@ export type OIDCConfigData = {
allowedEmailDomains?: string;
manageGroupMemberships: boolean;
jwtSignatureAlgorithm: OIDCJWTSignatureAlgorithm;
+ mfaClaimName: string;
+ mfaAmrValues?: string[] | null;
};
export enum OIDCJWTSignatureAlgorithm {
diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsx
index f08ac1af4a..7db6e6f46c 100644
--- a/frontend/src/hooks/api/organization/queries.tsx
+++ b/frontend/src/hooks/api/organization/queries.tsx
@@ -142,6 +142,7 @@ export const useUpdateOrg = () => {
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
+ ssoMfaTrust,
allowSecretSharingOutsideOrganization,
bypassOrgAuthEnabled,
userTokenExpiration,
@@ -166,6 +167,7 @@ export const useUpdateOrg = () => {
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
+ ssoMfaTrust,
allowSecretSharingOutsideOrganization,
bypassOrgAuthEnabled,
userTokenExpiration,
diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.ts
index 40c812a7ec..b27dbeb349 100644
--- a/frontend/src/hooks/api/organization/types.ts
+++ b/frontend/src/hooks/api/organization/types.ts
@@ -3,6 +3,11 @@ import { IdentityMembershipOrg } from "@app/hooks/api/identities/types";
import { MfaMethod } from "../auth/types";
+export enum SsoMfaTrust {
+ None = "none",
+ Signal = "signal"
+}
+
export type TSecretShareBrandConfig = {
primaryColor?: string;
secondaryColor?: string;
@@ -22,6 +27,7 @@ export type Organization = {
defaultMembershipRole: string;
enforceMfa: boolean;
selectedMfaMethod?: MfaMethod;
+ ssoMfaTrust: SsoMfaTrust;
shouldUseNewPrivilegeSystem: boolean;
allowSecretSharingOutsideOrganization?: boolean;
userTokenExpiration?: string;
@@ -54,6 +60,7 @@ export type UpdateOrgDTO = {
defaultMembershipRoleSlug?: string;
enforceMfa?: boolean;
selectedMfaMethod?: MfaMethod;
+ ssoMfaTrust?: SsoMfaTrust;
allowSecretSharingOutsideOrganization?: boolean;
bypassOrgAuthEnabled?: boolean;
userTokenExpiration?: string;
diff --git a/frontend/src/hooks/api/ssoConfig/queries.tsx b/frontend/src/hooks/api/ssoConfig/queries.tsx
index 95d10996d2..b46dc98334 100644
--- a/frontend/src/hooks/api/ssoConfig/queries.tsx
+++ b/frontend/src/hooks/api/ssoConfig/queries.tsx
@@ -37,7 +37,9 @@ export const useCreateSSOConfig = () => {
entryPoint,
issuer,
cert,
- enableGroupSync
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
}: {
organizationId: string;
authProvider: string;
@@ -46,6 +48,8 @@ export const useCreateSSOConfig = () => {
issuer: string;
cert: string;
enableGroupSync?: boolean;
+ mfaSignalAttribute?: string;
+ mfaAuthnContexts?: string[] | null;
}) => {
const { data } = await apiRequest.post("/api/v1/sso/config", {
organizationId,
@@ -54,7 +58,9 @@ export const useCreateSSOConfig = () => {
entryPoint,
issuer,
cert,
- ...(enableGroupSync !== undefined ? { enableGroupSync } : {})
+ ...(enableGroupSync !== undefined ? { enableGroupSync } : {}),
+ ...(mfaSignalAttribute !== undefined ? { mfaSignalAttribute } : {}),
+ ...(mfaAuthnContexts !== undefined ? { mfaAuthnContexts } : {})
});
return data;
@@ -77,7 +83,9 @@ export const useUpdateSSOConfig = () => {
entryPoint,
issuer,
cert,
- enableGroupSync
+ enableGroupSync,
+ mfaSignalAttribute,
+ mfaAuthnContexts
}: {
organizationId: string;
authProvider?: string;
@@ -86,6 +94,8 @@ export const useUpdateSSOConfig = () => {
issuer?: string;
cert?: string;
enableGroupSync?: boolean;
+ mfaSignalAttribute?: string;
+ mfaAuthnContexts?: string[] | null;
}) => {
const { data } = await apiRequest.patch("/api/v1/sso/config", {
organizationId,
@@ -94,7 +104,9 @@ export const useUpdateSSOConfig = () => {
...(entryPoint !== undefined ? { entryPoint } : {}),
...(issuer !== undefined ? { issuer } : {}),
...(cert !== undefined ? { cert } : {}),
- ...(enableGroupSync !== undefined ? { enableGroupSync } : {})
+ ...(enableGroupSync !== undefined ? { enableGroupSync } : {}),
+ ...(mfaSignalAttribute !== undefined ? { mfaSignalAttribute } : {}),
+ ...(mfaAuthnContexts !== undefined ? { mfaAuthnContexts } : {})
});
return data;
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
index 007c7d2828..478cb23313 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OIDCModal.tsx
@@ -1,7 +1,7 @@
-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";
+import { EyeIcon, EyeOffIcon, Trash2 } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -15,14 +15,18 @@ import {
AlertDialogHeader,
AlertDialogMedia,
AlertDialogTitle,
+ Badge,
Button,
DocumentationLinkBadge,
Field,
FieldDescription,
FieldError,
- FieldGroup,
FieldLabel,
Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
Select,
SelectContent,
SelectItem,
@@ -32,15 +36,22 @@ import {
SheetContent,
SheetFooter,
SheetHeader,
- SheetTitle
+ SheetTitle,
+ Tabs,
+ TabsList,
+ TabsTrigger,
+ TagsInput
} from "@app/components/v3";
import { useOrganization } from "@app/context";
import { useToggle } from "@app/hooks";
import { useGetOIDCConfig } from "@app/hooks/api";
import { useCreateOIDCConfig, useUpdateOIDCConfig } from "@app/hooks/api/oidcConfig/mutations";
import { OIDCJWTSignatureAlgorithm } from "@app/hooks/api/oidcConfig/types";
+import { SsoMfaTrust } from "@app/hooks/api/organization/types";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { FieldHint, FormSection } from "./SsoFormSection";
+
enum ConfigurationType {
CUSTOM = "custom",
DISCOVERY_URL = "discoveryURL"
@@ -63,9 +74,19 @@ const schema = z
tokenEndpoint: z.string().optional(),
userinfoEndpoint: z.string().optional(),
clientId: z.string().min(1, "Client ID is required"),
- clientSecret: z.string().min(1, "Client Secret is required"),
+ clientSecret: z.string().optional(),
allowedEmailDomains: z.string().optional(),
- jwtSignatureAlgorithm: z.nativeEnum(OIDCJWTSignatureAlgorithm).optional()
+ jwtSignatureAlgorithm: z.nativeEnum(OIDCJWTSignatureAlgorithm).optional(),
+ mfaClaimName: z
+ .string()
+ .trim()
+ .min(1, "Claim name is required")
+ .max(128, "Claim name is too long")
+ .default("amr"),
+ mfaAmrValues: z
+ .array(z.string().trim().min(1).max(64, "Value is too long"))
+ .max(20, "At most 20 values")
+ .optional()
})
.superRefine((data, ctx) => {
if (data.configurationType === ConfigurationType.CUSTOM) {
@@ -121,19 +142,19 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
const { mutateAsync: createMutateAsync, isPending: createIsLoading } = useCreateOIDCConfig();
const { mutateAsync: updateMutateAsync, isPending: updateIsLoading } = useUpdateOIDCConfig();
const [isDeletePopupOpen, setIsDeletePopupOpen] = useToggle(false);
+ const [isClientSecretRevealed, setIsClientSecretRevealed] = useState(false);
const { data } = useGetOIDCConfig(currentOrg?.id ?? "");
- const { control, handleSubmit, reset, setValue, watch } = useForm<OIDCFormData>({
+ const { control, handleSubmit, reset, setValue, setError, watch } = useForm<OIDCFormData>({
resolver: zodResolver(schema),
defaultValues: {
- configurationType: ConfigurationType.DISCOVERY_URL
+ configurationType: ConfigurationType.DISCOVERY_URL,
+ mfaClaimName: "amr",
+ mfaAmrValues: []
}
});
- const [isClientIdFocused, setIsClientIdFocused] = useToggle();
- const [isClientSecretFocused, setIsClientSecretFocused] = useToggle();
-
const configurationTypeValue = watch("configurationType");
const handleOidcSoftDelete = async () => {
@@ -158,6 +179,7 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
});
};
+ // The stored secret never returns to the form; a blank field on update keeps it.
useEffect(() => {
if (data) {
setValue("issuer", data.issuer);
@@ -167,13 +189,18 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
setValue("userinfoEndpoint", data.userinfoEndpoint);
setValue("discoveryURL", data.discoveryURL);
setValue("clientId", data.clientId);
- setValue("clientSecret", data.clientSecret);
- setValue("allowedEmailDomains", data.allowedEmailDomains);
+ setValue("clientSecret", "");
+ setValue("allowedEmailDomains", data.allowedEmailDomains ?? "");
setValue("configurationType", data.configurationType);
setValue("jwtSignatureAlgorithm", data.jwtSignatureAlgorithm);
+ setValue("mfaClaimName", data.mfaClaimName || "amr");
+ setValue("mfaAmrValues", data.mfaAmrValues ?? []);
}
}, [data]);
+ const isExistingConfig = Boolean(data?.isActive);
+ const hasStoredSecret = Boolean(data?.clientSecret);
+
const onOIDCModalSubmit = async ({
issuer,
authorizationEndpoint,
@@ -185,7 +212,9 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
discoveryURL,
clientId,
clientSecret,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues
}: OIDCFormData) => {
if (!currentOrg) return;
@@ -199,16 +228,21 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
tokenEndpoint,
userinfoEndpoint,
clientId,
- clientSecret,
isActive: true,
organizationId: currentOrg.id,
- jwtSignatureAlgorithm
+ jwtSignatureAlgorithm,
+ mfaClaimName,
+ mfaAmrValues: mfaAmrValues && mfaAmrValues.length > 0 ? mfaAmrValues : null
};
if (!data) {
- await createMutateAsync(payload);
+ if (!clientSecret) {
+ setError("clientSecret", { message: "Client Secret is required" });
+ return;
+ }
+ await createMutateAsync({ ...payload, clientSecret });
} else {
- await updateMutateAsync(payload);
+ await updateMutateAsync({ ...payload, ...(clientSecret ? { clientSecret } : {}) });
}
handlePopUpClose("addOIDC");
@@ -220,7 +254,31 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
};
const isPending = createIsLoading || updateIsLoading;
- const isExistingConfig = Boolean(data?.isActive);
+ const isMfaSignalInUse = currentOrg?.ssoMfaTrust === SsoMfaTrust.Signal;
+
+ const urlField = (
+ name: "issuer" | "authorizationEndpoint" | "tokenEndpoint" | "jwksUri" | "userinfoEndpoint",
+ label: string,
+ placeholder: string
+ ) => (
+ <Controller
+ control={control}
+ name={name}
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor={`oidc-${name}`}>{label}</FieldLabel>
+ <Input
+ id={`oidc-${name}`}
+ placeholder={placeholder}
+ autoComplete="off"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ );
return (
<>
@@ -229,6 +287,7 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
onOpenChange={(isOpen) => {
handlePopUpToggle("addOIDC", isOpen);
reset();
+ setIsClientSecretRevealed(false);
}}
>
<SheetContent className="sm:max-w-xl">
@@ -239,30 +298,27 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
<DocumentationLinkBadge href="https://infisical.com/docs/integrations/user-authentication" />
</SheetTitle>
</SheetHeader>
- <div className="thin-scrollbar flex-1 overflow-y-auto p-4">
- <FieldGroup>
+ <div className="thin-scrollbar flex-1 overflow-y-auto">
+ <FormSection
+ title="Identity Provider"
+ description="How Infisical locates your IdP's OIDC endpoints."
+ >
<Controller
control={control}
name="configurationType"
- render={({ field: { onChange, value }, fieldState: { error } }) => (
+ render={({ field: { onChange, value } }) => (
<Field>
- <FieldLabel htmlFor="oidc-configuration-type">Configuration Type</FieldLabel>
- <Select value={value} onValueChange={onChange}>
- <SelectTrigger
- id="oidc-configuration-type"
- className="w-full"
- isError={Boolean(error)}
- >
- <SelectValue placeholder="Select configuration type" />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value={ConfigurationType.DISCOVERY_URL}>
+ <FieldLabel>Configuration Type</FieldLabel>
+ <Tabs value={value} onValueChange={onChange}>
+ <TabsList variant="filled" className="grid w-full grid-cols-2">
+ <TabsTrigger value={ConfigurationType.DISCOVERY_URL}>
Discovery URL
- </SelectItem>
- <SelectItem value={ConfigurationType.CUSTOM}>Custom</SelectItem>
- </SelectContent>
- </Select>
- <FieldError>{error?.message}</FieldError>
+ </TabsTrigger>
+ <TabsTrigger value={ConfigurationType.CUSTOM}>
+ Custom Endpoints
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
</Field>
)}
/>
@@ -275,7 +331,7 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
<FieldLabel htmlFor="oidc-discovery-url">Discovery Document URL</FieldLabel>
<Input
id="oidc-discovery-url"
- placeholder="https://accounts.google.com/.well-known/openid-configuration"
+ placeholder="https://idp.example.com/.well-known/openid-configuration"
autoComplete="off"
isError={Boolean(error)}
{...field}
@@ -287,95 +343,19 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
)}
{configurationTypeValue === ConfigurationType.CUSTOM && (
<>
- <Controller
- control={control}
- name="issuer"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="oidc-issuer">Issuer</FieldLabel>
- <Input
- id="oidc-issuer"
- placeholder="https://accounts.google.com"
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="authorizationEndpoint"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="oidc-authorization-endpoint">
- Authorization Endpoint
- </FieldLabel>
- <Input
- id="oidc-authorization-endpoint"
- placeholder="https://accounts.google.com/o/oauth2/v2/auth"
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="tokenEndpoint"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="oidc-token-endpoint">Token Endpoint</FieldLabel>
- <Input
- id="oidc-token-endpoint"
- placeholder="https://oauth2.googleapis.com/token"
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="userinfoEndpoint"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="oidc-userinfo-endpoint">
- Userinfo Endpoint
- </FieldLabel>
- <Input
- id="oidc-userinfo-endpoint"
- placeholder="https://openidconnect.googleapis.com/v1/userinfo"
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="jwksUri"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="oidc-jwks-uri">JWKS URI</FieldLabel>
- <Input
- id="oidc-jwks-uri"
- placeholder="https://www.googleapis.com/oauth2/v3/certs"
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ {urlField("issuer", "Issuer", "https://idp.example.com")}
+ {urlField(
+ "authorizationEndpoint",
+ "Authorization Endpoint",
+ "https://idp.example.com/authorize"
+ )}
+ {urlField("tokenEndpoint", "Token Endpoint", "https://idp.example.com/token")}
+ {urlField("jwksUri", "JWKS URI", "https://idp.example.com/jwks")}
+ {urlField(
+ "userinfoEndpoint",
+ "Userinfo Endpoint",
+ "https://idp.example.com/userinfo"
+ )}
</>
)}
<Controller
@@ -384,12 +364,7 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
name="jwtSignatureAlgorithm"
render={({ field: { onChange, value }, fieldState: { error } }) => (
<Field>
- <FieldLabel
- htmlFor="oidc-jwt-algorithm"
- className="inline-flex flex-wrap items-baseline gap-1.5"
- >
- JWT Signature Algorithm
- </FieldLabel>
+ <FieldLabel htmlFor="oidc-jwt-algorithm">JWT Signature Algorithm</FieldLabel>
<Select value={value} onValueChange={onChange}>
<SelectTrigger
id="oidc-jwt-algorithm"
@@ -409,16 +384,81 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
</Field>
)}
/>
+ </FormSection>
+
+ <FormSection
+ title="Client Credentials"
+ description="From the OIDC client you registered for Infisical in your IdP."
+ >
+ <Controller
+ control={control}
+ name="clientId"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="oidc-client-id">Client ID</FieldLabel>
+ <Input
+ id="oidc-client-id"
+ className="font-mono"
+ placeholder="infisical-web"
+ autoComplete="off"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="clientSecret"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="oidc-client-secret">Client Secret</FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ id="oidc-client-secret"
+ type={isClientSecretRevealed ? "text" : "password"}
+ placeholder={
+ hasStoredSecret
+ ? "Stored. Enter a new value to replace it."
+ : "Client Secret"
+ }
+ autoComplete="new-password"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ aria-label={
+ isClientSecretRevealed ? "Hide client secret" : "Show client secret"
+ }
+ onClick={() => setIsClientSecretRevealed((previous) => !previous)}
+ >
+ {isClientSecretRevealed ? <EyeOffIcon /> : <EyeIcon />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ {hasStoredSecret && (
+ <FieldDescription>Leave blank to keep the current secret.</FieldDescription>
+ )}
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ </FormSection>
+
+ <FormSection
+ title="Access"
+ description="Limit which users can sign in through this IdP."
+ >
<Controller
control={control}
name="allowedEmailDomains"
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel
- htmlFor="oidc-allowed-domains"
- className="inline-flex flex-wrap items-baseline gap-1.5"
- >
- Allowed Email Domains (optional)
+ <FieldLabel htmlFor="oidc-allowed-domains">
+ Allowed Email Domains
+ <FieldHint>Optional</FieldHint>
</FieldLabel>
<Input
id="oidc-allowed-domains"
@@ -428,59 +468,64 @@ export const OIDCModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
{...field}
/>
<FieldDescription>
- Defaults to any. Supports wildcards (e.g. *.example.com).
+ Any domain is allowed if empty. Supports wildcards, e.g. *.example.com.
</FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
/>
+ </FormSection>
+
+ <FormSection
+ title="MFA Signal"
+ description="Read when Trust IdP MFA is on, to decide whether to skip the Infisical MFA prompt."
+ badge={isMfaSignalInUse ? <Badge variant="success">In use</Badge> : undefined}
+ >
<Controller
control={control}
- name="clientId"
+ name="mfaClaimName"
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="oidc-client-id">Client ID</FieldLabel>
+ <FieldLabel htmlFor="oidc-mfa-claim-name">MFA Claim Name</FieldLabel>
<Input
- id="oidc-client-id"
- placeholder="Client ID"
- type={isClientIdFocused ? "text" : "password"}
+ id="oidc-mfa-claim-name"
+ className="font-mono"
+ placeholder="amr"
autoComplete="off"
isError={Boolean(error)}
- onFocus={() => setIsClientIdFocused.on()}
{...field}
- onBlur={() => {
- field.onBlur();
- setIsClientIdFocused.off();
- }}
/>
+ <FieldDescription>
+ ID token claim listing the authentication methods the user completed.
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
/>
<Controller
control={control}
- name="clientSecret"
- render={({ field, fieldState: { error } }) => (
+ name="mfaAmrValues"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="oidc-client-secret">Client Secret</FieldLabel>
- <Input
- id="oidc-client-secret"
- placeholder="Client Secret"
- type={isClientSecretFocused ? "text" : "password"}
- autoComplete="off"
+ <FieldLabel htmlFor="oidc-mfa-amr-values">
+ Additional MFA Claim Values
+ <FieldHint>Optional</FieldHint>
+ </FieldLabel>
+ <TagsInput
+ id="oidc-mfa-amr-values"
+ placeholder="Type a value, press Enter"
+ value={value ?? []}
+ onValueChange={onChange}
isError={Boolean(error)}
- onFocus={() => setIsClientSecretFocused.on()}
- {...field}
- onBlur={() => {
- field.onBlur();
- setIsClientSecretFocused.off();
- }}
/>
+ <FieldDescription>
+ Counted as MFA in addition to the standard <code>mfa</code> value.
+ </FieldDescription>
<FieldError>{error?.message}</FieldError>
</Field>
)}
/>
- </FieldGroup>
+ </FormSection>
</div>
<SheetFooter className="justify-between border-t">
<div className="flex gap-2">
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgGeneralAuthSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgGeneralAuthSection.tsx
index 70adfc7aae..fd7e535fcb 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgGeneralAuthSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgGeneralAuthSection.tsx
@@ -1,5 +1,6 @@
import { useState } from "react";
-import { AlertTriangle, Info, ShieldCheck } from "lucide-react";
+import { Link } from "@tanstack/react-router";
+import { AlertTriangle, ShieldCheck } from "lucide-react";
import { twMerge } from "tailwind-merge";
import { SsoEnforcementUpgradeIntent, UpgradeGate } from "@app/components/license/UpgradeGate";
@@ -27,9 +28,6 @@ import {
FieldDescription,
FieldGroup,
FieldTitle,
- HoverCard,
- HoverCardContent,
- HoverCardTrigger,
Toggle
} from "@app/components/v3";
import {
@@ -41,6 +39,8 @@ import {
import { useLogoutUser, useUpdateOrg } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
+import { SsoMfaTrustField } from "./SsoMfaTrustField";
+
enum EnforceAuthType {
SAML = "saml",
GOOGLE = "google",
@@ -253,7 +253,7 @@ export const OrgGeneralAuthSection = ({
Enforcement
{isAnySsoEnforced && <Badge variant="success">Active</Badge>}
</CardTitle>
- <CardDescription>Require all members to sign in via your IDP.</CardDescription>
+ <CardDescription>Require all members to sign in via your IdP.</CardDescription>
</CardHeader>
<CardContent>
<FieldGroup>
@@ -263,10 +263,7 @@ export const OrgGeneralAuthSection = ({
>
<FieldContent>
<FieldTitle>Enforce SAML SSO</FieldTitle>
- <FieldDescription>
- Only allow members to sign in via SAML. Also disables email & password signup for
- your verified domain(s) and skips email verification for SSO sign-ins.
- </FieldDescription>
+ <FieldDescription>Members can only sign in via SAML.</FieldDescription>
</FieldContent>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
@@ -289,10 +286,7 @@ export const OrgGeneralAuthSection = ({
>
<FieldContent>
<FieldTitle>Enforce OIDC SSO</FieldTitle>
- <FieldDescription>
- Only allow members to sign in via OIDC. Also disables email & password signup for
- your verified domain(s) and skips email verification for SSO sign-ins.
- </FieldDescription>
+ <FieldDescription>Members can only sign in via OIDC.</FieldDescription>
</FieldContent>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
@@ -317,9 +311,7 @@ export const OrgGeneralAuthSection = ({
>
<FieldContent>
<FieldTitle>Enforce Google OAuth</FieldTitle>
- <FieldDescription>
- Only allow members to sign in via Google OAuth (not SAML).
- </FieldDescription>
+ <FieldDescription>Members can only sign in via Google OAuth.</FieldDescription>
</FieldContent>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
@@ -336,59 +328,54 @@ export const OrgGeneralAuthSection = ({
</OrgPermissionCan>
</Field>
- <Field orientation="horizontal">
- <FieldContent>
- <FieldTitle>
- Enable Admin SSO Bypass
- <HoverCard openDelay={150} closeDelay={150}>
- <HoverCardTrigger asChild>
- <Info className="text-muted" />
- </HoverCardTrigger>
- <HoverCardContent className="w-80">
- <p>
- Enable org-level MFA before turning this on — without a second factor, an
- admin password is the weakest way into the org.
- </p>
- <p className="mt-3 mb-0.5">
- If locked out, admins can sign in via the{" "}
- <a
- target="_blank"
- rel="noreferrer"
- className="underline underline-offset-2 hover:text-foreground"
- href="https://infisical.com/docs/documentation/platform/sso/overview#sso-break-glass"
- >
- Admin Login Portal
- </a>{" "}
- at{" "}
- <a
- target="_blank"
- rel="noopener noreferrer"
- className="underline underline-offset-2 hover:text-foreground"
- href={`${window.location.origin}/login/admin`}
- >
- /login/admin
- </a>
- .
- </p>
- </HoverCardContent>
- </HoverCard>
- </FieldTitle>
- <FieldDescription>
- Admins can sign in with a password if your IDP is inaccessible.
- </FieldDescription>
- </FieldContent>
- <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
- {(isAllowed) => (
- <Toggle
- id="allow-admin-bypass"
- variant="org"
- checked={currentOrg?.bypassOrgAuthEnabled ?? false}
- onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
- disabled={!isAllowed}
- />
- )}
- </OrgPermissionCan>
- </Field>
+ <div className="ml-1 border-l border-border pl-4">
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>Admin SSO Bypass</FieldTitle>
+ <FieldDescription>
+ Admins can sign in with a password at{" "}
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ className="font-mono underline underline-offset-2 hover:text-foreground"
+ href={`${window.location.origin}/login/admin`}
+ >
+ /login/admin
+ </a>{" "}
+ if your IdP is inaccessible.
+ </FieldDescription>
+ </FieldContent>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Toggle
+ id="allow-admin-bypass"
+ variant="org"
+ checked={currentOrg?.bypassOrgAuthEnabled ?? false}
+ onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
+ disabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </Field>
+ {isAnySsoEnforced && currentOrg?.bypassOrgAuthEnabled && !currentOrg?.enforceMfa && (
+ <Alert variant="warning" className="mt-3">
+ <AlertTriangle />
+ <AlertDescription>
+ Org MFA is off, so bypass is password-only.{" "}
+ <Link
+ to="/organizations/$orgId/settings"
+ params={{ orgId: currentOrg.id }}
+ search={{ selectedTab: "tab-org-security" }}
+ className="underline underline-offset-2 hover:text-foreground"
+ >
+ Enforce MFA
+ </Link>
+ </AlertDescription>
+ </Alert>
+ )}
+ </div>
+
+ <SsoMfaTrustField isSsoActive={isSamlActive || isOidcActive} />
</FieldGroup>
</CardContent>
</Card>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
index f99b264d9f..5a97dd6a00 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModal.tsx
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { ClipboardCheckIcon, Copy, Trash2 } from "lucide-react";
+import { ExternalLinkIcon, Trash2 } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -15,13 +15,14 @@ import {
AlertDialogHeader,
AlertDialogMedia,
AlertDialogTitle,
+ Badge,
Button,
+ CopyButton,
DocumentationLinkBadge,
Field,
+ FieldDescription,
FieldError,
- FieldGroup,
FieldLabel,
- IconButton,
Input,
Select,
SelectContent,
@@ -33,17 +34,16 @@ import {
SheetFooter,
SheetHeader,
SheetTitle,
- TextArea,
- Tooltip,
- TooltipContent,
- TooltipTrigger
+ TagsInput,
+ TextArea
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { useTimedReset, useToggle } from "@app/hooks";
+import { useToggle } from "@app/hooks";
import { useCreateSSOConfig, useGetSSOConfig, useUpdateSSOConfig } from "@app/hooks/api";
+import { SsoMfaTrust } from "@app/hooks/api/organization/types";
import { UsePopUpState } from "@app/hooks/usePopUp";
-import { SSOModalHeader } from "./SSOModalHeader";
+import { FieldHint, FormSection } from "./SsoFormSection";
enum AuthProvider {
OKTA_SAML = "okta-saml",
@@ -54,41 +54,124 @@ enum AuthProvider {
AUTH0_SAML = "auth0-saml"
}
+const docsBaseUrl = "https://infisical.com/docs/documentation/platform/sso";
+
const ssoAuthProviders = [
- { label: "Okta SAML", value: AuthProvider.OKTA_SAML, image: "Okta.png", docsUrl: "okta" },
- {
- label: "Azure / Entra SAML",
- value: AuthProvider.AZURE_SAML,
- image: "Microsoft Azure.png",
- docsUrl: "azure"
- },
- {
- label: "JumpCloud SAML",
- value: AuthProvider.JUMPCLOUD_SAML,
- image: "JumpCloud.png",
- docsUrl: "jumpcloud"
- },
- {
- label: "Keycloak SAML",
- value: AuthProvider.KEYCLOAK_SAML,
- image: "Keycloak.png",
- docsUrl: "keycloak-saml"
- },
- {
- label: "Google SAML",
- value: AuthProvider.GOOGLE_SAML,
- image: "Google.png",
- docsUrl: "google-saml"
- },
- { label: "Auth0 SAML", value: AuthProvider.AUTH0_SAML, image: "Auth0.png", docsUrl: "auth0-saml" }
+ { name: "Okta", value: AuthProvider.OKTA_SAML, docsUrl: "okta" },
+ { name: "Azure / Entra", value: AuthProvider.AZURE_SAML, docsUrl: "azure" },
+ { name: "JumpCloud", value: AuthProvider.JUMPCLOUD_SAML, docsUrl: "jumpcloud" },
+ { name: "Keycloak", value: AuthProvider.KEYCLOAK_SAML, docsUrl: "keycloak-saml" },
+ { name: "Google", value: AuthProvider.GOOGLE_SAML, docsUrl: "google-saml" },
+ { name: "Auth0", value: AuthProvider.AUTH0_SAML, docsUrl: "auth0-saml" }
];
+// Labels as each provider's console names them. A hint gives the generic SAML term when the label hides it.
+type TProviderLabels = {
+ acsUrl: string;
+ acsHint?: string;
+ entityId: string;
+ entityHint?: string;
+ entryPoint: string;
+ entryPointPlaceholder: string;
+ issuer: string;
+ issuerHint?: string;
+ issuerPlaceholder: string;
+};
+
+const providerLabels = (authProvider: string): TProviderLabels => {
+ switch (authProvider) {
+ case AuthProvider.OKTA_SAML:
+ return {
+ acsUrl: "Single Sign-On URL",
+ acsHint: "ACS URL",
+ entityId: "Audience URI (SP Entity ID)",
+ entryPoint: "Identity Provider Single Sign-On URL",
+ entryPointPlaceholder: "https://your-domain.okta.com/app/app-name/xxx/sso/saml",
+ issuer: "Identity Provider Issuer",
+ issuerHint: "IdP Entity ID",
+ issuerPlaceholder: "http://www.okta.com/xxx"
+ };
+ case AuthProvider.AZURE_SAML:
+ return {
+ acsUrl: "Reply URL",
+ acsHint: "ACS URL",
+ entityId: "Identifier (Entity ID)",
+ entityHint: "SP Entity ID",
+ entryPoint: "Login URL",
+ entryPointPlaceholder: "https://login.microsoftonline.com/xxx/saml2",
+ issuer: "Azure / Entra Application ID",
+ issuerPlaceholder: "abc-def-ghi-jkl-mno"
+ };
+ case AuthProvider.JUMPCLOUD_SAML:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "SP Entity ID",
+ entryPoint: "IdP URL",
+ entryPointPlaceholder: "https://sso.jumpcloud.com/saml2/xxx",
+ issuer: "IdP Entity ID",
+ issuerPlaceholder: "JumpCloud"
+ };
+ case AuthProvider.KEYCLOAK_SAML:
+ return {
+ acsUrl: "Valid Redirect URI",
+ acsHint: "ACS URL",
+ entityId: "Client ID",
+ entityHint: "SP Entity ID",
+ entryPoint: "IdP URL",
+ entryPointPlaceholder: "https://keycloak.mysite.com/realms/myrealm/protocol/saml",
+ issuer: "Client ID",
+ issuerPlaceholder: window.origin
+ };
+ case AuthProvider.GOOGLE_SAML:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "Entity ID",
+ entityHint: "SP Entity ID",
+ entryPoint: "SSO URL",
+ entryPointPlaceholder: "https://accounts.google.com/o/saml2/idp?idpid=xxx",
+ issuer: "Entity ID",
+ issuerPlaceholder: window.origin
+ };
+ case AuthProvider.AUTH0_SAML:
+ return {
+ acsUrl: "Application Callback URL",
+ acsHint: "ACS URL",
+ entityId: "Audience",
+ entityHint: "SP Entity ID",
+ entryPoint: "Identity Provider Login URL",
+ entryPointPlaceholder: "https://xxx.auth0.com/samlp/xxx",
+ issuer: "Issuer",
+ issuerHint: "IdP Entity ID",
+ issuerPlaceholder: "urn:xxx.auth0.com"
+ };
+ default:
+ return {
+ acsUrl: "ACS URL",
+ entityId: "SP Entity ID",
+ entryPoint: "IdP SSO URL",
+ entryPointPlaceholder: "https://idp.example.com/sso/saml",
+ issuer: "IdP Entity ID",
+ issuerPlaceholder: "https://idp.example.com"
+ };
+ }
+};
+
const schema = z
.object({
authProvider: z.string().min(1, "SSO Type is required"),
entryPoint: z.string().trim().min(1, "URL required"),
issuer: z.string().trim().min(1, "Issuer required"),
- cert: z.string().default("")
+ cert: z.string().default(""),
+ mfaSignalAttribute: z
+ .string()
+ .trim()
+ .min(1, "Attribute name is required")
+ .max(512, "Attribute name is too long")
+ .default("amr"),
+ mfaAuthnContexts: z
+ .array(z.string().trim().min(1).max(512, "Context value is too long"))
+ .max(20, "At most 20 contexts")
+ .default([])
})
.required();
@@ -101,6 +184,21 @@ type Props = {
hideDelete?: boolean;
};
+const CopyableValue = ({ label, hint, value }: { label: string; hint?: string; value: string }) => (
+ <Field>
+ <FieldLabel>
+ {label}
+ {hint && <FieldHint>{hint}</FieldHint>}
+ </FieldLabel>
+ <div className="flex items-start gap-2">
+ <div className="min-w-0 flex-1 rounded-md border border-border bg-foreground/5 px-3 py-2 font-mono text-sm break-all">
+ {value}
+ </div>
+ <CopyButton value={value} ariaLabel={`Copy ${label}`} variant="outline" size="md" />
+ </div>
+ </Field>
+);
+
export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelete }: Props) => {
const { currentOrg } = useOrganization();
@@ -111,7 +209,9 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
const { control, handleSubmit, reset, watch, setValue, getValues } = useForm<AddSSOFormData>({
defaultValues: {
- authProvider: AuthProvider.OKTA_SAML
+ authProvider: AuthProvider.OKTA_SAML,
+ mfaSignalAttribute: "amr",
+ mfaAuthnContexts: []
},
resolver: zodResolver(schema)
});
@@ -122,7 +222,9 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
authProvider: data?.authProvider ?? "",
entryPoint: data?.entryPoint ?? "",
issuer: data?.issuer ?? "",
- cert: data?.cert ?? ""
+ cert: data?.cert ?? "",
+ mfaSignalAttribute: data?.mfaSignalAttribute || "amr",
+ mfaAuthnContexts: data?.mfaAuthnContexts ?? []
});
}
}, [data]);
@@ -145,27 +247,31 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
});
};
- const onSSOModalSubmit = async ({ authProvider, entryPoint, issuer, cert }: AddSSOFormData) => {
+ const onSSOModalSubmit = async ({
+ authProvider,
+ entryPoint,
+ issuer,
+ cert,
+ mfaSignalAttribute,
+ mfaAuthnContexts
+ }: AddSSOFormData) => {
if (!currentOrg) return;
+ const payload = {
+ organizationId: currentOrg.id,
+ authProvider,
+ isActive: false,
+ entryPoint,
+ issuer,
+ cert,
+ mfaSignalAttribute,
+ mfaAuthnContexts: mfaAuthnContexts.length > 0 ? mfaAuthnContexts : null
+ };
+
if (!data) {
- await createMutateAsync({
- organizationId: currentOrg.id,
- authProvider,
- isActive: false,
- entryPoint,
- issuer,
- cert
- });
+ await createMutateAsync(payload);
} else {
- await updateMutateAsync({
- organizationId: currentOrg.id,
- authProvider,
- isActive: false,
- entryPoint,
- issuer,
- cert
- });
+ await updateMutateAsync(payload);
}
handlePopUpClose("addSSO");
@@ -176,77 +282,6 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
});
};
- const [, isAcsCopied, setAcsCopied] = useTimedReset<string>({ initialState: "" });
- const [, isAudienceCopied, setAudienceCopied] = useTimedReset<string>({ initialState: "" });
-
- const renderLabels = (authProvider: string) => {
- switch (authProvider) {
- case AuthProvider.OKTA_SAML:
- return {
- acsUrl: "Single sign-on URL",
- entityId: "Audience URI (SP Entity ID)",
- entryPoint: "Identity Provider Single Sign-On URL",
- entryPointPlaceholder: "https://your-domain.okta.com/app/app-name/xxx/sso/saml",
- issuer: "Identity Provider Issuer",
- issuerPlaceholder: "http://www.okta.com/xxx"
- };
- case AuthProvider.AZURE_SAML:
- return {
- acsUrl: "Reply URL (Assertion Consumer Service URL)",
- entityId: "Identifier (Entity ID)",
- entryPoint: "Login URL",
- entryPointPlaceholder: "https://login.microsoftonline.com/xxx/saml2",
- issuer: "Azure / Entra Application ID",
- issuerPlaceholder: "abc-def-ghi-jkl-mno"
- };
- case AuthProvider.JUMPCLOUD_SAML:
- return {
- acsUrl: "ACS URL",
- entityId: "SP Entity ID",
- entryPoint: "IDP URL",
- entryPointPlaceholder: "https://sso.jumpcloud.com/saml2/xxx",
- issuer: "IdP Entity ID",
- issuerPlaceholder: "xxx"
- };
- case AuthProvider.KEYCLOAK_SAML:
- return {
- acsUrl: "Valid redirect URI",
- entityId: "SP Entity ID",
- entryPoint: "IDP URL",
- entryPointPlaceholder: "https://keycloak.mysite.com/realms/myrealm/protocol/saml",
- issuer: "Client ID",
- issuerPlaceholder: window.origin
- };
- case AuthProvider.GOOGLE_SAML:
- return {
- acsUrl: "ACS URL",
- entityId: "SP Entity ID",
- entryPoint: "SSO URL",
- entryPointPlaceholder: "https://accounts.google.com/o/saml2/idp?idpid=xxx",
- issuer: "Issuer",
- issuerPlaceholder: window.origin
- };
- case AuthProvider.AUTH0_SAML:
- return {
- acsUrl: "Application Callback URL",
- entityId: "Audience",
- entryPoint: "Identity Provider Login URL",
- entryPointPlaceholder: "https://xxx.auth0.com/samlp/xxx",
- issuer: "Issuer",
- issuerPlaceholder: "urn:xxx-xxx.us.auth0.com"
- };
- default:
- return {
- acsUrl: "ACS URL",
- entityId: "Entity ID",
- entryPoint: "Entrypoint",
- entryPointPlaceholder: "Enter entrypoint...",
- issuer: "Issuer",
- issuerPlaceholder: "Enter placeholder..."
- };
- }
- };
-
const authProvider = watch("authProvider");
useEffect(() => {
if (authProvider === AuthProvider.GOOGLE_SAML && getValues("issuer") === "") {
@@ -255,7 +290,10 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
}, [authProvider]);
const isPending = createIsLoading || updateIsLoading;
- const labels = renderLabels(authProvider);
+ const labels = providerLabels(authProvider);
+ const provider = ssoAuthProviders.find((item) => item.value === authProvider);
+ const providerName = provider?.name ?? "your IdP";
+ const isMfaSignalInUse = currentOrg?.ssoMfaTrust === SsoMfaTrust.Signal;
return (
<>
@@ -274,33 +312,47 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
<DocumentationLinkBadge href="https://infisical.com/docs/integrations/user-authentication" />
</SheetTitle>
</SheetHeader>
- <div className="thin-scrollbar flex-1 overflow-y-auto p-4">
- <SSOModalHeader
- providerDetails={
- ssoAuthProviders.find((provider) => provider.value === authProvider)!
- }
- isConnected={Boolean(data)}
- />
- <FieldGroup>
+ <div className="thin-scrollbar flex-1 overflow-y-auto">
+ <FormSection
+ title="Identity Provider"
+ description="Field names below match what your provider calls them."
+ >
<Controller
control={control}
name="authProvider"
defaultValue="okta-saml"
render={({ field: { onChange, value }, fieldState: { error } }) => (
<Field>
- <FieldLabel htmlFor="sso-auth-provider">Type</FieldLabel>
+ <FieldLabel
+ htmlFor="sso-auth-provider"
+ className="flex items-center justify-between"
+ >
+ Provider
+ {provider && (
+ <Badge variant="info" iconPosition="right" asChild>
+ <a
+ href={`${docsBaseUrl}/${provider.docsUrl}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ {provider.name} Documentation
+ <ExternalLinkIcon />
+ </a>
+ </Badge>
+ )}
+ </FieldLabel>
<Select value={value} onValueChange={onChange}>
<SelectTrigger
id="sso-auth-provider"
className="w-full"
isError={Boolean(error)}
>
- <SelectValue placeholder="Select SSO type" />
+ <SelectValue placeholder="Select a provider" />
</SelectTrigger>
<SelectContent position="popper">
- {ssoAuthProviders.map(({ label, value: providerValue }) => (
- <SelectItem value={providerValue} key={label}>
- {label}
+ {ssoAuthProviders.map(({ name, value: providerValue }) => (
+ <SelectItem value={providerValue} key={providerValue}>
+ {name}
</SelectItem>
))}
</SelectContent>
@@ -309,119 +361,147 @@ export const SSOModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDelet
</Field>
)}
/>
- {authProvider && data && (
- <>
+ </FormSection>
+
+ {data && (
+ <FormSection
+ title={`Add Infisical to ${providerName}`}
+ description={`Copy these values into the SAML app you create in ${providerName}.`}
+ >
+ <CopyableValue
+ label={labels.acsUrl}
+ hint={labels.acsHint}
+ value={`${window.origin}/api/v1/sso/saml2/${data.id}`}
+ />
+ <CopyableValue
+ label={labels.entityId}
+ hint={labels.entityHint}
+ value={window.origin}
+ />
+ </FormSection>
+ )}
+
+ <FormSection
+ title={`Connect ${providerName} to Infisical`}
+ description={`Paste the values ${providerName} shows for the SAML app.`}
+ >
+ <Controller
+ control={control}
+ name="entryPoint"
+ render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel className="flex items-center justify-between">
- {labels.acsUrl}
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- aria-label="copy application callback url"
- variant="ghost-muted"
- size="xs"
- onClick={() => {
- navigator.clipboard.writeText(
- `${window.origin}/api/v1/sso/saml2/${data.id}`
- );
- setAcsCopied("copied");
- }}
- >
- {isAcsCopied ? <ClipboardCheckIcon /> : <Copy />}
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>{isAcsCopied ? "Copied" : "Copy"}</TooltipContent>
- </Tooltip>
+ <FieldLabel htmlFor="sso-entry-point">
+ {labels.entryPoint}
+ <FieldHint>IdP SSO URL</FieldHint>
+ </FieldLabel>
+ <Input
+ id="sso-entry-point"
+ placeholder={labels.entryPointPlaceholder}
+ autoComplete="off"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="issuer"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="sso-issuer">
+ {labels.issuer}
+ {labels.issuerHint && <FieldHint>{labels.issuerHint}</FieldHint>}
</FieldLabel>
- <p className="text-muted-foreground text-sm break-all">
- {`${window.origin}/api/v1/sso/saml2/${data.id}`}
- </p>
+ <Input
+ id="sso-issuer"
+ placeholder={labels.issuerPlaceholder}
+ autoComplete="off"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
</Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="cert"
+ render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel className="flex items-center justify-between">
- {labels.entityId}
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- aria-label="copy audience"
- variant="ghost-muted"
- size="xs"
- onClick={() => {
- navigator.clipboard.writeText(window.origin);
- setAudienceCopied("copied");
- }}
- >
- {isAudienceCopied ? <ClipboardCheckIcon /> : <Copy />}
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>{isAudienceCopied ? "Copied" : "Copy"}</TooltipContent>
- </Tooltip>
+ <FieldLabel htmlFor="sso-cert">
+ X.509 Certificate
+ <FieldHint>Optional</FieldHint>
+ </FieldLabel>
+ <TextArea
+ id="sso-cert"
+ className="font-mono"
+ placeholder="-----BEGIN CERTIFICATE----- ..."
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldDescription>
+ Used to verify the signature on SAML responses from {providerName}.
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ </FormSection>
+
+ <FormSection
+ title="MFA Signal"
+ description="Read when Trust IdP MFA is on, to decide whether to skip the Infisical MFA prompt."
+ badge={isMfaSignalInUse ? <Badge variant="success">In use</Badge> : undefined}
+ >
+ <Controller
+ control={control}
+ name="mfaSignalAttribute"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="sso-mfa-signal-attribute">MFA Attribute Name</FieldLabel>
+ <Input
+ id="sso-mfa-signal-attribute"
+ className="font-mono"
+ placeholder="amr"
+ autoComplete="off"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldDescription>
+ Attribute in the {providerName} SAML assertion that lists the authentication
+ methods the user completed.
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="mfaAuthnContexts"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="sso-mfa-authn-contexts">
+ Additional MFA Authentication Contexts
+ <FieldHint>Optional</FieldHint>
</FieldLabel>
- <p className="text-muted-foreground text-sm">{window.origin}</p>
+ <TagsInput
+ id="sso-mfa-authn-contexts"
+ placeholder="urn:oasis:names:tc:SAML:2.0:ac:classes:..."
+ value={value}
+ onValueChange={onChange}
+ isError={Boolean(error)}
+ />
+ <FieldDescription>
+ AuthnContextClassRef values counted as MFA, in addition to the standard
+ two-factor classes. Press Enter to add.
+ </FieldDescription>
+ <FieldError>{error?.message}</FieldError>
</Field>
- <Controller
- control={control}
- name="entryPoint"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="sso-entry-point">{labels.entryPoint}</FieldLabel>
- <Input
- id="sso-entry-point"
- placeholder={labels.entryPointPlaceholder}
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="issuer"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel
- htmlFor="sso-issuer"
- className="inline-flex flex-wrap items-baseline gap-1.5"
- >
- {labels.issuer}
- </FieldLabel>
- <Input
- id="sso-issuer"
- placeholder={labels.issuerPlaceholder}
- autoComplete="off"
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="cert"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel
- htmlFor="sso-cert"
- className="inline-flex flex-wrap items-baseline gap-1.5"
- >
- Certificate (optional)
- </FieldLabel>
- <TextArea
- id="sso-cert"
- placeholder="-----BEGIN CERTIFICATE----- ..."
- isError={Boolean(error)}
- {...field}
- />
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- </>
- )}
- </FieldGroup>
+ )}
+ />
+ </FormSection>
</div>
<SheetFooter className="justify-between border-t">
<div className="flex gap-2">
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModalHeader.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModalHeader.tsx
deleted file mode 100644
index 002792dc0d..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SSOModalHeader.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { DocumentationLinkBadge } from "@app/components/v3";
-
-type ProviderDetails = {
- label: string;
- image: string;
- value: string;
- docsUrl: string;
-};
-
-type Props = {
- providerDetails: ProviderDetails;
- isConnected: boolean;
-};
-
-const docsBaseUrl = "https://infisical.com/docs/documentation/platform/sso";
-
-export const SSOModalHeader = ({ providerDetails, isConnected }: Props) => {
- return (
- <div className="mb-4 flex w-full items-start gap-2 border-b border-border-strong pb-4">
- <img
- alt={`${providerDetails.label} logo`}
- src={`/images/sso/${providerDetails.image}`}
- className="h-10 w-10 rounded-md bg-foreground/5 p-1.5"
- />
- <div>
- <div className="flex items-center gap-x-2 text-label">
- {providerDetails.label}
- <DocumentationLinkBadge href={`${docsBaseUrl}/${providerDetails.docsUrl}`} />
- </div>
- <p className="text-sm leading-4 text-muted">
- {isConnected
- ? `${providerDetails.label} Connection`
- : `Connect to ${providerDetails.label}`}
- </p>
- </div>
- </div>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx
new file mode 100644
index 0000000000..dedcfb0b48
--- /dev/null
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoFormSection.tsx
@@ -0,0 +1,28 @@
+import { ReactNode } from "react";
+
+import { FieldGroup } from "@app/components/v3";
+
+export const FormSection = ({
+ title,
+ description,
+ badge,
+ children
+}: {
+ title: string;
+ description: string;
+ badge?: ReactNode;
+ children: ReactNode;
+}) => (
+ <section className="border-b border-border px-4 py-5 last:border-b-0">
+ <h3 className="flex items-center gap-2 font-medium text-foreground">
+ {title}
+ {badge}
+ </h3>
+ <p className="mt-1 mb-4 text-sm text-muted">{description}</p>
+ <FieldGroup>{children}</FieldGroup>
+ </section>
+);
+
+export const FieldHint = ({ children }: { children: ReactNode }) => (
+ <span className="ml-1.5 font-normal text-muted">{children}</span>
+);
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoMfaTrustField.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoMfaTrustField.tsx
new file mode 100644
index 0000000000..eed18fcfd6
--- /dev/null
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/SsoMfaTrustField.tsx
@@ -0,0 +1,98 @@
+import { MfaEnforcementUpgradeIntent, UpgradeGate } from "@app/components/license/UpgradeGate";
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Badge,
+ Field,
+ FieldContent,
+ FieldDescription,
+ FieldTitle,
+ Toggle,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
+import {
+ OrgPermissionSsoActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { useUpdateOrg } from "@app/hooks/api";
+import { SsoMfaTrust } from "@app/hooks/api/organization/types";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+type Props = {
+ isSsoActive: boolean;
+};
+
+export const SsoMfaTrustField = ({ isSsoActive }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);
+ const { mutateAsync } = useUpdateOrg();
+
+ const handleToggle = async (value: boolean) => {
+ if (!currentOrg?.id) return;
+ if (value && !subscription?.enforceMfa) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg.id,
+ ssoMfaTrust: value ? SsoMfaTrust.Signal : SsoMfaTrust.None
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} IdP MFA trust`,
+ type: "success"
+ });
+ };
+
+ return (
+ <>
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>
+ Trust IdP MFA
+ {!currentOrg?.enforceMfa && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant="shaded">No effect</Badge>
+ </TooltipTrigger>
+ <TooltipContent>
+ Applies once Enforce MFA is on under Security. Until then every login is prompted
+ as usual.
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </FieldTitle>
+ <FieldDescription>
+ Skip the Infisical MFA prompt for SAML and OIDC logins that completed MFA at your IdP.
+ </FieldDescription>
+ </FieldContent>
+ <OrgPermissionCan I={OrgPermissionSsoActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Toggle
+ id="trust-idp-mfa"
+ variant="org"
+ checked={currentOrg?.ssoMfaTrust === SsoMfaTrust.Signal}
+ onCheckedChange={handleToggle}
+ disabled={!isAllowed || !isSsoActive}
+ />
+ )}
+ </OrgPermissionCan>
+ </Field>
+ <UpgradeGate
+ paywallKey="organization.org-sso-mfa"
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ intent={{
+ ...MfaEnforcementUpgradeIntent,
+ isEnterpriseFeature: false
+ }}
+ />
+ </>
+ );
+};