Skip to content

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

feat(notifications): project access request notification

x032205f9ca58c8b967
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index c0e7827c27..73fb1c8c13 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1231,7 +1231,8 @@ export const registerRoutes = async (
projectTemplateService,
groupProjectDAL,
smtpService,
- reminderService
+ reminderService,
+ notificationService
});
const projectEnvService = projectEnvServiceFactory({
diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.ts
index 0d0cf1f156..a6727cde94 100644
--- a/backend/src/services/notification/notification-types.ts
+++ b/backend/src/services/notification/notification-types.ts
@@ -12,7 +12,8 @@ export enum NotificationType {
IMPORT_STARTED = "import-started",
IMPORT_SUCCESSFUL = "import-successful",
IMPORT_FAILED = "import-failed",
- DIRECT_PROJECT_ACCESS_ISSUED_TO_ADMIN = "direct-project-access-issued-to-admin"
+ DIRECT_PROJECT_ACCESS_ISSUED_TO_ADMIN = "direct-project-access-issued-to-admin",
+ PROJECT_ACCESS_REQUEST = "project-access-request"
}
export interface TCreateUserNotificationDTO {
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts
index 57539f0022..8dbba2b4f1 100644
--- a/backend/src/services/project/project-service.ts
+++ b/backend/src/services/project/project-service.ts
@@ -57,6 +57,8 @@ import { TKmsServiceFactory } from "../kms/kms-service";
import { validateMicrosoftTeamsChannelsSchema } from "../microsoft-teams/microsoft-teams-fns";
import { TMicrosoftTeamsIntegrationDALFactory } from "../microsoft-teams/microsoft-teams-integration-dal";
import { TProjectMicrosoftTeamsConfigDALFactory } from "../microsoft-teams/project-microsoft-teams-config-dal";
+import { TNotificationServiceFactory } from "../notification/notification-service";
+import { NotificationType } from "../notification/notification-types";
import { TOrgDALFactory } from "../org/org-dal";
import { TPkiAlertDALFactory } from "../pki-alert/pki-alert-dal";
import { TPkiCollectionDALFactory } from "../pki-collection/pki-collection-dal";
@@ -183,6 +185,7 @@ type TProjectServiceFactoryDep = {
>;
projectTemplateService: TProjectTemplateServiceFactory;
reminderService: Pick<TReminderServiceFactory, "deleteReminderBySecretId">;
+ notificationService: Pick<TNotificationServiceFactory, "createUserNotifications">;
};
export type TProjectServiceFactory = ReturnType<typeof projectServiceFactory>;
@@ -227,7 +230,8 @@ export const projectServiceFactory = ({
projectTemplateService,
groupProjectDAL,
smtpService,
- reminderService
+ reminderService,
+ notificationService
}: TProjectServiceFactoryDep) => {
/*
* Create workspace. Make user the admin
@@ -1924,6 +1928,21 @@ export const projectServiceFactory = ({
projectTypeUrl = "cert-management";
}
+ const callbackPath = `/projects/${projectTypeUrl}/${project.id}/access-management?selectedTab=members&requesterEmail=${userDetails.email}`;
+
+ await notificationService.createUserNotifications(
+ projectMembers
+ .filter((member) => member.roles.some((role) => role.role === ProjectMembershipRole.Admin))
+ .map((member) => ({
+ userId: member.userId,
+ orgId: project.orgId,
+ type: NotificationType.PROJECT_ACCESS_REQUEST,
+ title: "Project Access Request",
+ body: `**${userDetails.firstName} ${userDetails.lastName}** (${userDetails.email}) has requested access to the project **${project.name}**.`,
+ link: callbackPath
+ }))
+ );
+
await smtpService.sendMail({
template: SmtpTemplates.ProjectAccessRequest,
recipients: filteredProjectMembers,
@@ -1934,7 +1953,7 @@ export const projectServiceFactory = ({
projectName: project?.name,
orgName: org?.name,
note: comment,
- callback_url: `${appCfg.SITE_URL}/projects/${projectTypeUrl}/${project.id}/access-management?selectedTab=members&requesterEmail=${userDetails.email}`
+ callback_url: `${appCfg.SITE_URL}${callbackPath}`
}
});
};