Skip to content

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

misc: made bypass opt-in

Sheen Capadngan76c3f1c152f0
diff --git a/backend/src/db/migrations/20250416145120_add-enable-bypass-org-auth-flag.ts b/backend/src/db/migrations/20250416145120_add-enable-bypass-org-auth-flag.ts
new file mode 100644
index 0000000000..ef2957545a
--- /dev/null
+++ b/backend/src/db/migrations/20250416145120_add-enable-bypass-org-auth-flag.ts
@@ -0,0 +1,19 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ if (!(await knex.schema.hasColumn(TableName.Organization, "enableBypassOrgAuth"))) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.boolean("enableBypassOrgAuth").defaultTo(false).notNullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasColumn(TableName.Organization, "enableBypassOrgAuth")) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.dropColumn("enableBypassOrgAuth");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.ts
index a18e258c7b..3e475fda15 100644
--- a/backend/src/db/schemas/organizations.ts
+++ b/backend/src/db/schemas/organizations.ts
@@ -26,7 +26,8 @@ export const OrganizationsSchema = z.object({
allowSecretSharingOutsideOrganization: z.boolean().default(true).nullable().optional(),
shouldUseNewPrivilegeSystem: z.boolean().default(true),
privilegeUpgradeInitiatedByUsername: z.string().nullable().optional(),
- privilegeUpgradeInitiatedAt: z.date().nullable().optional()
+ privilegeUpgradeInitiatedAt: z.date().nullable().optional(),
+ enableBypassOrgAuth: z.boolean().default(false)
});
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
diff --git a/backend/src/ee/services/permission/permission-dal.ts b/backend/src/ee/services/permission/permission-dal.ts
index b76403400f..410e4d48ea 100644
--- a/backend/src/ee/services/permission/permission-dal.ts
+++ b/backend/src/ee/services/permission/permission-dal.ts
@@ -54,6 +54,7 @@ export const permissionDALFactory = (db: TDbClient) => {
db.ref("slug").withSchema(TableName.OrgRoles).withSchema(TableName.OrgRoles).as("customRoleSlug"),
db.ref("permissions").withSchema(TableName.OrgRoles),
db.ref("authEnforced").withSchema(TableName.Organization).as("orgAuthEnforced"),
+ db.ref("enableBypassOrgAuth").withSchema(TableName.Organization).as("enableBypassOrgAuth"),
db.ref("groupId").withSchema("userGroups"),
db.ref("groupOrgId").withSchema("userGroups"),
db.ref("groupName").withSchema("userGroups"),
@@ -72,6 +73,7 @@ export const permissionDALFactory = (db: TDbClient) => {
OrgMembershipsSchema.extend({
permissions: z.unknown(),
orgAuthEnforced: z.boolean().optional().nullable(),
+ enableBypassOrgAuth: z.boolean(),
customRoleSlug: z.string().optional().nullable(),
shouldUseNewPrivilegeSystem: z.boolean()
}).parse(el),
@@ -676,6 +678,7 @@ export const permissionDALFactory = (db: TDbClient) => {
db.ref("key").withSchema(TableName.IdentityMetadata).as("metadataKey"),
db.ref("value").withSchema(TableName.IdentityMetadata).as("metadataValue"),
db.ref("authEnforced").withSchema(TableName.Organization).as("orgAuthEnforced"),
+ db.ref("enableBypassOrgAuth").withSchema(TableName.Organization).as("enableBypassOrgAuth"),
db.ref("role").withSchema(TableName.OrgMembership).as("orgRole"),
db.ref("orgId").withSchema(TableName.Project),
db.ref("type").withSchema(TableName.Project).as("projectType"),
@@ -698,7 +701,8 @@ export const permissionDALFactory = (db: TDbClient) => {
groupMembershipUpdatedAt,
membershipUpdatedAt,
projectType,
- shouldUseNewPrivilegeSystem
+ shouldUseNewPrivilegeSystem,
+ enableBypassOrgAuth
}) => ({
orgId,
orgAuthEnforced,
@@ -710,7 +714,8 @@ export const permissionDALFactory = (db: TDbClient) => {
id: membershipId || groupMembershipId,
createdAt: membershipCreatedAt || groupMembershipCreatedAt,
updatedAt: membershipUpdatedAt || groupMembershipUpdatedAt,
- shouldUseNewPrivilegeSystem
+ shouldUseNewPrivilegeSystem,
+ enableBypassOrgAuth
}),
childrenMapper: [
{
diff --git a/backend/src/ee/services/permission/permission-fns.ts b/backend/src/ee/services/permission/permission-fns.ts
index 410fc58198..e532afe058 100644
--- a/backend/src/ee/services/permission/permission-fns.ts
+++ b/backend/src/ee/services/permission/permission-fns.ts
@@ -121,14 +121,18 @@ function isAuthMethodSaml(actorAuthMethod: ActorAuthMethod) {
function validateOrgSSO(
actorAuthMethod: ActorAuthMethod,
isOrgSsoEnforced: TOrganizations["authEnforced"],
+ isOrgSsoBypassEnabled: TOrganizations["enableBypassOrgAuth"],
orgRole: OrgMembershipRole
) {
if (actorAuthMethod === undefined) {
throw new UnauthorizedError({ name: "No auth method defined" });
}
+ if (isOrgSsoEnforced && isOrgSsoBypassEnabled && orgRole === OrgMembershipRole.Admin) {
+ return;
+ }
+
if (
- orgRole !== OrgMembershipRole.Admin &&
isOrgSsoEnforced &&
actorAuthMethod !== null &&
!isAuthMethodSaml(actorAuthMethod) &&
diff --git a/backend/src/ee/services/permission/permission-service.ts b/backend/src/ee/services/permission/permission-service.ts
index 0a63931aa6..69dadec001 100644
--- a/backend/src/ee/services/permission/permission-service.ts
+++ b/backend/src/ee/services/permission/permission-service.ts
@@ -139,7 +139,12 @@ export const permissionServiceFactory = ({
throw new ForbiddenRequestError({ name: "You are not logged into this organization" });
}
- validateOrgSSO(authMethod, membership.orgAuthEnforced, membership.role as OrgMembershipRole);
+ validateOrgSSO(
+ authMethod,
+ membership.orgAuthEnforced,
+ membership.enableBypassOrgAuth,
+ membership.role as OrgMembershipRole
+ );
const finalPolicyRoles = [{ role: membership.role, permissions: membership.permissions }].concat(
membership?.groups?.map(({ role, customRolePermission }) => ({
@@ -226,7 +231,12 @@ export const permissionServiceFactory = ({
throw new ForbiddenRequestError({ name: "You are not logged into this organization" });
}
- validateOrgSSO(authMethod, userProjectPermission.orgAuthEnforced, userProjectPermission.orgRole);
+ validateOrgSSO(
+ authMethod,
+ userProjectPermission.orgAuthEnforced,
+ userProjectPermission.enableBypassOrgAuth,
+ userProjectPermission.orgRole
+ );
if (actionProjectType !== ActionProjectType.Any && actionProjectType !== userProjectPermission.projectType) {
throw new BadRequestError({
diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.ts
index c6391d4f70..25c3ea7f2f 100644
--- a/backend/src/server/routes/v1/organization-router.ts
+++ b/backend/src/server/routes/v1/organization-router.ts
@@ -260,7 +260,8 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
defaultMembershipRoleSlug: slugSchema({ max: 64, field: "Default Membership Role" }).optional(),
enforceMfa: z.boolean().optional(),
selectedMfaMethod: z.nativeEnum(MfaMethod).optional(),
- allowSecretSharingOutsideOrganization: z.boolean().optional()
+ allowSecretSharingOutsideOrganization: z.boolean().optional(),
+ enableBypassOrgAuth: z.boolean().optional()
}),
response: {
200: z.object({
diff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.ts
index ef49d81786..7b5825e349 100644
--- a/backend/src/services/org/org-schema.ts
+++ b/backend/src/services/org/org-schema.ts
@@ -16,5 +16,6 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
allowSecretSharingOutsideOrganization: true,
shouldUseNewPrivilegeSystem: true,
privilegeUpgradeInitiatedByUsername: true,
- privilegeUpgradeInitiatedAt: true
+ privilegeUpgradeInitiatedAt: true,
+ enableBypassOrgAuth: true
});
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index 98b35f68fc..a5df934d26 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -349,7 +349,8 @@ export const orgServiceFactory = ({
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
- allowSecretSharingOutsideOrganization
+ allowSecretSharingOutsideOrganization,
+ enableBypassOrgAuth
}
}: TUpdateOrgDTO) => {
const appCfg = getConfig();
@@ -429,7 +430,8 @@ export const orgServiceFactory = ({
defaultMembershipRole,
enforceMfa,
selectedMfaMethod,
- allowSecretSharingOutsideOrganization
+ allowSecretSharingOutsideOrganization,
+ enableBypassOrgAuth
});
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
return org;
diff --git a/backend/src/services/org/org-types.ts b/backend/src/services/org/org-types.ts
index 9d14b092e6..136e6cc848 100644
--- a/backend/src/services/org/org-types.ts
+++ b/backend/src/services/org/org-types.ts
@@ -73,6 +73,7 @@ export type TUpdateOrgDTO = {
enforceMfa: boolean;
selectedMfaMethod: MfaMethod;
allowSecretSharingOutsideOrganization: boolean;
+ enableBypassOrgAuth: boolean;
}>;
} & TOrgPermission;
diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsx
index 90e525cdfc..5bc6c2c7bf 100644
--- a/frontend/src/hooks/api/organization/queries.tsx
+++ b/frontend/src/hooks/api/organization/queries.tsx
@@ -110,7 +110,8 @@ export const useUpdateOrg = () => {
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
- allowSecretSharingOutsideOrganization
+ allowSecretSharingOutsideOrganization,
+ enableBypassOrgAuth
}) => {
return apiRequest.patch(`/api/v1/organization/${orgId}`, {
name,
@@ -120,7 +121,8 @@ export const useUpdateOrg = () => {
defaultMembershipRoleSlug,
enforceMfa,
selectedMfaMethod,
- allowSecretSharingOutsideOrganization
+ allowSecretSharingOutsideOrganization,
+ enableBypassOrgAuth
});
},
onSuccess: () => {
diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.ts
index 6eeebd8193..302b635de1 100644
--- a/frontend/src/hooks/api/organization/types.ts
+++ b/frontend/src/hooks/api/organization/types.ts
@@ -9,6 +9,7 @@ export type Organization = {
createAt: string;
updatedAt: string;
authEnforced: boolean;
+ enableBypassOrgAuth: boolean;
orgAuthMethod: string;
scimEnabled: boolean;
slug: string;
@@ -30,6 +31,7 @@ export type UpdateOrgDTO = {
enforceMfa?: boolean;
selectedMfaMethod?: MfaMethod;
allowSecretSharingOutsideOrganization?: boolean;
+ enableBypassOrgAuth?: boolean;
};
export type BillingDetails = {
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
index 7dbf8d4572..601ce08b9e 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
@@ -69,7 +69,10 @@ export const SelectOrganizationPage = () => {
const handleSelectOrganization = useCallback(
async (organization: Organization) => {
- if (organization.authEnforced && organization.userRole !== OrgMembershipRole.Admin) {
+ const canBypassOrgAuth =
+ organization.enableBypassOrgAuth && organization.userRole === OrgMembershipRole.Admin;
+
+ if (organization.authEnforced && !canBypassOrgAuth) {
// org has an org-level auth method enabled (e.g. SAML)
// -> logout + redirect to SAML SSO
await logout.mutateAsync();
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx
index 291934208c..462fd75d79 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx
@@ -55,6 +55,28 @@ export const OrgGeneralAuthSection = () => {
}
};
+ const handleEnableBypassOrgAuthToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.oidcSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await mutateAsync({
+ orgId: currentOrg?.id,
+ enableBypassOrgAuth: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} admin bypassing of org-level auth`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
return (
<>
{/* <div className="py-4">
@@ -77,35 +99,6 @@ export const OrgGeneralAuthSection = () => {
<div className="mb-2 flex justify-between">
<div className="flex items-center gap-1">
<span className="text-md text-mineshaft-100">Enforce SAML SSO</span>
- <Tooltip
- className="max-w-lg"
- content={
- <div>
- <span>
- Login enforcement is only applied to non-admin users in order to prevent total
- lockout from the organization when the SAML provider is unavailable.
- </span>
-
- <p className="mt-4">
- In case of a lockout, use the admin login portal{" "}
- <a
- target="_blank"
- rel="noopener noreferrer"
- className="underline underline-offset-2 hover:text-mineshaft-300"
- href={`${window.location.origin}/admin/login`}
- >
- here.
- </a>
- </p>
- </div>
- }
- >
- <FontAwesomeIcon
- icon={faInfoCircle}
- size="sm"
- className="mt-0.5 inline-block text-mineshaft-400"
- />
- </Tooltip>
</div>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
@@ -119,9 +112,44 @@ export const OrgGeneralAuthSection = () => {
</OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">
- Enforce non-admin users to authenticate via SAML to access this organization
+ Enforce users to authenticate via SAML to access this organization
</p>
</div>
+ {currentOrg?.authEnforced && (
+ <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <div className="flex items-center gap-1">
+ <span className="text-md text-mineshaft-100">Enable Admin SSO Bypass</span>
+ <Tooltip
+ className="max-w-lg"
+ content="When this is enabled, we strongly recommend enforcing MFA at the organization level."
+ >
+ <FontAwesomeIcon
+ icon={faInfoCircle}
+ size="sm"
+ className="mt-0.5 inline-block text-mineshaft-400"
+ />
+ </Tooltip>
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="allow-admin-bypass"
+ isChecked={currentOrg?.enableBypassOrgAuth ?? false}
+ onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ <span>
+ Allow organization admins to bypass OIDC enforcement when SSO is unavailable,
+ misconfigured, or inaccessible.
+ </span>
+ </p>
+ </div>
+ )}
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgOIDCSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgOIDCSection.tsx
index a494115a31..33fbd4aebe 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgOIDCSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgAuthTab/OrgOIDCSection.tsx
@@ -82,6 +82,28 @@ export const OrgOIDCSection = (): JSX.Element => {
}
};
+ const handleEnableBypassOrgAuthToggle = async (value: boolean) => {
+ try {
+ if (!currentOrg?.id) return;
+ if (!subscription?.oidcSSO) {
+ handlePopUpOpen("upgradePlan");
+ return;
+ }
+
+ await updateOrg({
+ orgId: currentOrg?.id,
+ enableBypassOrgAuth: value
+ });
+
+ createNotification({
+ text: `Successfully ${value ? "enabled" : "disabled"} admin bypassing of org-level auth`,
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
const handleOIDCGroupManagement = async (value: boolean) => {
try {
if (!currentOrg?.id) return;
@@ -160,35 +182,6 @@ export const OrgOIDCSection = (): JSX.Element => {
<div className="mb-2 flex justify-between">
<div className="flex items-center gap-1">
<span className="text-md text-mineshaft-100">Enforce OIDC SSO</span>
- <Tooltip
- className="max-w-lg"
- content={
- <div>
- <span>
- Login enforcement is only applied to non-admin users in order to prevent total
- lockout from the organization when the OIDC provider is unavailable.
- </span>
-
- <p className="mt-4">
- In case of a lockout, use the admin login portal{" "}
- <a
- target="_blank"
- rel="noopener noreferrer"
- className="underline underline-offset-2 hover:text-mineshaft-300"
- href={`${window.location.origin}/admin/login`}
- >
- here.
- </a>
- </p>
- </div>
- }
- >
- <FontAwesomeIcon
- icon={faInfoCircle}
- size="sm"
- className="mt-0.5 inline-block text-mineshaft-400"
- />
- </Tooltip>
</div>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
@@ -202,9 +195,44 @@ export const OrgOIDCSection = (): JSX.Element => {
</OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">
- <span>Enforce non-admin users to authenticate via OIDC to access this organization.</span>
+ <span>Enforce users to authenticate via OIDC to access this organization.</span>
</p>
</div>
+ {currentOrg?.authEnforced && (
+ <div className="py-4">
+ <div className="mb-2 flex justify-between">
+ <div className="flex items-center gap-1">
+ <span className="text-md text-mineshaft-100">Enable Admin SSO Bypass</span>
+ <Tooltip
+ className="max-w-lg"
+ content="When this is enabled, we strongly recommend enforcing MFA at the organization level."
+ >
+ <FontAwesomeIcon
+ icon={faInfoCircle}
+ size="sm"
+ className="mt-0.5 inline-block text-mineshaft-400"
+ />
+ </Tooltip>
+ </div>
+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
+ {(isAllowed) => (
+ <Switch
+ id="allow-admin-bypass"
+ isChecked={currentOrg?.enableBypassOrgAuth ?? false}
+ onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
+ isDisabled={!isAllowed}
+ />
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="text-sm text-mineshaft-300">
+ <span>
+ Allow organization admins to bypass OIDC enforcement when SSO is unavailable,
+ misconfigured, or inaccessible.
+ </span>
+ </p>
+ </div>
+ )}
<div className="py-4">
<div className="mb-2 flex justify-between">
<div className="text-md flex items-center text-mineshaft-100">