Skip to content

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

feat(group-service): add ForbiddenRequestError for unauthorized group management

Victor Hugo dos Santosb145ca4a7bdc
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.ts
index 3dcb84a6fd..740a8fe34a 100644
--- a/backend/src/ee/services/group/group-service.ts
+++ b/backend/src/ee/services/group/group-service.ts
@@ -15,6 +15,7 @@ import { DatabaseErrorCode } from "@app/lib/error-codes";
import {
BadRequestError,
DatabaseError,
+ ForbiddenRequestError,
NotFoundError,
PermissionBoundaryError,
UnauthorizedError
@@ -1043,8 +1044,14 @@ export const groupServiceFactory = ({
message: `Failed to find group with ID ${id}`
});
+ if (groupMembership.group.orgId !== actorOrgId) {
+ throw new ForbiddenRequestError({
+ message: `Group '${groupMembership.group.slug}' is owned by a parent organization. Its members must be managed from that organization.`
+ });
+ }
+
const oidcConfig = await oidcConfigDAL.findOne({
- orgId: actorOrgId,
+ orgId: groupMembership.group.orgId,
isActive: true
});
@@ -1152,6 +1159,12 @@ export const groupServiceFactory = ({
message: `Failed to find group with ID ${id}`
});
+ if (groupMembership.group.orgId !== actorOrgId) {
+ throw new ForbiddenRequestError({
+ message: `Group '${groupMembership.group.slug}' is owned by a parent organization. Its members must be managed from that organization.`
+ });
+ }
+
const groupRoles = resolveMembershipRoleSlugs(groupMembership.roles);
const rolePermissionDetails = await permissionService.getOrgPermissionByRoles(groupRoles, actorOrgId, {
ignoreUnresolvedRoles: true
@@ -1234,6 +1247,12 @@ export const groupServiceFactory = ({
message: `Failed to find group with ID ${id}`
});
+ if (groupMembership.group.orgId !== actorOrgId) {
+ throw new ForbiddenRequestError({
+ message: `Group '${groupMembership.group.slug}' is owned by a parent organization. Its members must be managed from that organization.`
+ });
+ }
+
const oidcConfig = await oidcConfigDAL.findOne({
orgId: groupMembership.group.orgId,
isActive: true
@@ -1322,6 +1341,12 @@ export const groupServiceFactory = ({
message: `Failed to find group with ID ${id}`
});
+ if (groupMembership.group.orgId !== actorOrgId) {
+ throw new ForbiddenRequestError({
+ message: `Group '${groupMembership.group.slug}' is owned by a parent organization. Its members must be managed from that organization.`
+ });
+ }
+
const groupRoles = resolveMembershipRoleSlugs(groupMembership.roles);
const rolePermissionDetails = await permissionService.getOrgPermissionByRoles(groupRoles, actorOrgId, {
ignoreUnresolvedRoles: true