Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add new endpoint to get membership by userId and projectId
adilson936fbbc8ddc1
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 28f9bd966c..11bf0b31aa 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -1100,6 +1100,10 @@ export const PROJECT_USERS = {membershipId: "The ID of the user's project membership.",username: "The username to get project membership of. Email is the default username."},+ GET_USER_MEMBERSHIP_BY_USER_ID: {+ projectId: "The ID of the project to get the membership from.",+ userId: "The ID of the user to get the project membership of."+ },UPDATE_USER_MEMBERSHIP: {projectId: "The ID of the project to update the membership for.",membershipId: "The ID of the membership to update.",diff --git a/backend/src/server/routes/v1/project-membership-router.ts b/backend/src/server/routes/v1/project-membership-router.tsindex 7020992582..41c6971c5a 100644--- a/backend/src/server/routes/v1/project-membership-router.ts+++ b/backend/src/server/routes/v1/project-membership-router.ts@@ -152,6 +152,71 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider}});+ server.route({+ method: "GET",+ url: "/:projectId/user/:userId/membership",+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: "getProjectMembershipByUserId",+ tags: [ApiDocsTags.ProjectUsers],+ description: "Return a project user's membership by user ID",+ security: [+ {+ bearerAuth: []+ }+ ],+ params: z.object({+ projectId: z.string().min(1).uuid().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP_BY_USER_ID.projectId),+ userId: z.string().min(1).uuid().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP_BY_USER_ID.userId)+ }),+ response: {+ 200: z.object({+ membership: ProjectMembershipsSchema.extend({+ user: SanitizedUserSchema,+ roles: z.array(+ z.object({+ id: z.string(),+ role: z.string(),+ customRoleId: z.string().optional().nullable(),+ customRoleName: z.string().optional().nullable(),+ customRoleSlug: z.string().optional().nullable(),+ isTemporary: z.boolean(),+ temporaryMode: z.string().optional().nullable(),+ temporaryRange: z.string().nullable().optional(),+ temporaryAccessStartTime: z.date().nullable().optional(),+ temporaryAccessEndTime: z.date().nullable().optional()+ })+ )+ }).omit({ updatedAt: true })+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),+ handler: async (req) => {+ const membership = await server.services.membershipUser.getMembershipByUserId({+ permission: req.permission,+ scopeData: {+ scope: AccessScope.Project,+ orgId: req.permission.orgId,+ projectId: req.params.projectId+ },+ selector: {+ userId: req.params.userId+ }+ });++ return {+ membership: {+ ...membership,+ userId: req.params.userId,+ projectId: req.params.projectId+ }+ };+ }+ });+server.route({method: "GET",url: "/:projectId/memberships/:membershipId/permissions/audit",