Skip to content

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

Merge remote-tracking branch 'origin/main' into feat/enforce-oidc-sso

Sheen Capadngan32f866f83490
diff --cc backend/src/ee/services/permission/permission-fns.ts
index ce6e3a88f1,c4b38288a4..1ccee129fe
--- a/backend/src/ee/services/permission/permission-fns.ts
+++ b/backend/src/ee/services/permission/permission-fns.ts
@@@ -19,13 -19,8 +19,13 @@@ function validateOrgSSO(actorAuthMethod
throw new UnauthorizedError({ name: "No auth method defined" });
}
- if (isSamlEnforced && actorAuthMethod !== null && !isAuthMethodSaml(actorAuthMethod)) {
- throw new ForbiddenRequestError({ name: "SAML auth enforced, cannot access org-scoped resource" });
+ if (
+ isOrgSsoEnforced &&
+ actorAuthMethod !== null &&
+ !isAuthMethodSaml(actorAuthMethod) &&
+ actorAuthMethod !== AuthMethod.OIDC
+ ) {
- throw new UnauthorizedError({ name: "Cannot access org-scoped resource" });
++ throw new ForbiddenRequestError({ name: "Org auth enforced. Cannot access org-scoped resource" });
}
}
diff --cc backend/src/ee/services/permission/permission-service.ts
index 5b5fe45835,119ac6fca6..37c2c863b6
--- a/backend/src/ee/services/permission/permission-service.ts
+++ b/backend/src/ee/services/permission/permission-service.ts
@@@ -127,10 -127,10 +127,10 @@@ export const permissionServiceFactory
// Extra: This means that when users are using API keys to make requests, they can't use slug-based routes.
// Slug-based routes depend on the organization ID being present on the request, since project slugs aren't globally unique, and we need a way to filter by organization.
if (userOrgId !== "API_KEY" && membership.orgId !== userOrgId) {
- throw new UnauthorizedError({ name: "You are not logged into this organization" });
+ throw new ForbiddenRequestError({ name: "You are not logged into this organization" });
}
- validateOrgSAML(authMethod, membership.orgAuthEnforced);
+ validateOrgSSO(authMethod, membership.orgAuthEnforced);
const finalPolicyRoles = [{ role: membership.role, permissions: membership.permissions }].concat(
membership?.groups?.map(({ role, customRolePermission }) => ({
@@@ -210,10 -210,10 +210,10 @@@
// Extra: This means that when users are using API keys to make requests, they can't use slug-based routes.
// Slug-based routes depend on the organization ID being present on the request, since project slugs aren't globally unique, and we need a way to filter by organization.
if (userOrgId !== "API_KEY" && userProjectPermission.orgId !== userOrgId) {
- throw new UnauthorizedError({ name: "You are not logged into this organization" });
+ throw new ForbiddenRequestError({ name: "You are not logged into this organization" });
}
- validateOrgSAML(authMethod, userProjectPermission.orgAuthEnforced);
+ validateOrgSSO(authMethod, userProjectPermission.orgAuthEnforced);
// join two permissions and pass to build the final permission set
const rolePermissions = userProjectPermission.roles?.map(({ role, permissions }) => ({ role, permissions })) || [];
diff --cc backend/src/services/org/org-service.ts
index 2c349d7442,faa3adba6e..16dfa3f572
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@@ -287,12 -285,9 +287,11 @@@ export const orgServiceFactory = (
if (authEnforced) {
const samlCfg = await samlConfigDAL.findEnforceableSamlCfg(orgId);
- if (!samlCfg)
+ const oidcCfg = await oidcConfigDAL.findEnforceableOidcCfg(orgId);
+
+ if (!samlCfg && !oidcCfg)
- throw new BadRequestError({
- name: "No enforceable SSO config found",
+ throw new NotFoundError({
- message: "No enforceable SAML config found"
+ message: "No enforceable SSO config found"
});
}