Skip to content

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

fix: pr consideration

IgorHorta9611426de8d1
diff --git a/backend/src/ee/routes/v1/group-router.ts b/backend/src/ee/routes/v1/group-router.ts
index add298ca8c..baa08cc81b 100644
--- a/backend/src/ee/routes/v1/group-router.ts
+++ b/backend/src/ee/routes/v1/group-router.ts
@@ -222,7 +222,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
operationId: "addGroupToOrganization",
tags: [ApiDocsTags.Groups],
description:
- "Deprecated: Use POST /api/v1/organizations/memberships/groups/:groupId instead. Link this group to the current (sub-)organization with the given role. Only valid when the current org is a sub-org and the group belongs to the parent org.",
+ "Deprecated: Use POST /api/v1/organizations/memberships/groups/:groupId instead (pattern: {scope}/memberships/{actor-type}/{actor-id}). Link this group to the current (sub-)organization with the given role.",
params: z.object({
id: z.string().trim().describe("The ID of the group to link to the current organization")
}),
@@ -287,7 +287,7 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
operationId: "removeGroupFromOrganization",
tags: [ApiDocsTags.Groups],
description:
- "Deprecated: Use DELETE /api/v1/organizations/memberships/groups/:groupId instead. Unlink this group from the current (sub-)organization. Only valid when the group is linked (inherited) in the current org.",
+ "Deprecated: Use DELETE /api/v1/organizations/memberships/groups/:groupId instead (pattern: {scope}/memberships/{actor-type}/{actor-id}). Unlink this group from the current (sub-)organization.",
params: z.object({
id: z.string().trim().describe("The ID of the group to unlink from the current organization")
}),
diff --git a/backend/src/server/routes/v1/organization-memberships-router.ts b/backend/src/server/routes/v1/organization-memberships-router.ts
index e49a026015..00eba714c9 100644
--- a/backend/src/server/routes/v1/organization-memberships-router.ts
+++ b/backend/src/server/routes/v1/organization-memberships-router.ts
@@ -7,6 +7,12 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+/**
+ * Organization group memberships. Follows the membership pattern:
+ * - Pattern: {scope}/memberships/{actor-type} (list) and {scope}/memberships/{actor-type}/{actor-id} (by id).
+ * - Scope: organizations (org from token, no org id in path).
+ * - Actor type: groups. Resource: the membership (id, roles), not the group in isolation.
+ */
const orgGroupMembershipRoleSchema = z.object({
id: z.string(),
role: z.string(),
@@ -76,7 +82,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
groupMemberships: memberships.map((m) => ({
...m,
groupId: m.actorGroupId as string,
- group: m.group!
+ group: m.group
})),
totalCount
};
@@ -126,7 +132,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
}
},
handler: async (req) => {
- const { membership } = await server.services.membershipGroup.createMembership({
+ await server.services.membershipGroup.createMembership({
scopeData: {
scope: AccessScope.Organization,
orgId: req.permission.orgId
@@ -148,7 +154,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
groupMembership: {
...full,
groupId: full.actorGroupId as string,
- group: full.group!
+ group: full.group
}
};
}
@@ -188,7 +194,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
groupMembership: {
...membership,
groupId: membership.actorGroupId as string,
- group: membership.group!
+ group: membership.group
}
};
}
@@ -237,7 +243,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
}
},
handler: async (req) => {
- const { membership } = await server.services.membershipGroup.updateMembership({
+ await server.services.membershipGroup.updateMembership({
permission: req.permission,
scopeData: { scope: AccessScope.Organization, orgId: req.permission.orgId },
selector: { groupId: req.params.groupId },
@@ -254,7 +260,7 @@ export const registerOrganizationMembershipsRouter = async (server: FastifyZodPr
groupMembership: {
...full,
groupId: full.actorGroupId as string,
- group: full.group!
+ group: full.group
}
};
}
diff --git a/backend/src/server/routes/v1/project-group-memberships-router.ts b/backend/src/server/routes/v1/project-group-memberships-router.ts
index 843c042373..5aaf8db3be 100644
--- a/backend/src/server/routes/v1/project-group-memberships-router.ts
+++ b/backend/src/server/routes/v1/project-group-memberships-router.ts
@@ -13,6 +13,12 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+/**
+ * Project group memberships. Follows the membership pattern:
+ * - Pattern: {scope}/memberships/{actor-type} (list) and {scope}/memberships/{actor-type}/{actor-id} (by id).
+ * - Scope: projects/:projectId (explicit in path).
+ * - Actor type: groups. Resource: the membership (id, roles), not the group in isolation.
+ */
const projectGroupMembershipRoleSchema = z.object({
id: z.string(),
role: z.string(),
@@ -80,7 +86,7 @@ export const registerProjectGroupMembershipsRouter = async (server: FastifyZodPr
...el,
groupId: el.actorGroupId as string,
projectId: req.params.projectId,
- group: el.group!
+ group: el.group
}))
};
}
@@ -137,7 +143,7 @@ export const registerProjectGroupMembershipsRouter = async (server: FastifyZodPr
},
handler: async (req) => {
const roles = req.body.roles || [{ role: req.body.role!, isTemporary: false }];
- const { membership } = await server.services.membershipGroup.createMembership({
+ await server.services.membershipGroup.createMembership({
permission: req.permission,
data: { groupId: req.params.groupId, roles },
scopeData: {
@@ -162,7 +168,7 @@ export const registerProjectGroupMembershipsRouter = async (server: FastifyZodPr
...full,
groupId: full.actorGroupId as string,
projectId: req.params.projectId,
- group: full.group!
+ group: full.group
}
};
}
@@ -208,7 +214,7 @@ export const registerProjectGroupMembershipsRouter = async (server: FastifyZodPr
...membership,
groupId: membership.actorGroupId as string,
projectId: req.params.projectId,
- group: membership.group!
+ group: membership.group
}
};
}
@@ -296,7 +302,8 @@ export const registerProjectGroupMembershipsRouter = async (server: FastifyZodPr
}),
response: {
200: z.object({
- groupMembership: projectGroupMembershipSchema.pick({ id: true, groupId: true, projectId: true })
+ groupMembership: projectGroupMembershipSchema
+ .pick({ id: true, groupId: true, projectId: true })
.extend({ createdAt: z.date(), updatedAt: z.date() })
})
}