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
simplify to only use users/groups
Thiago Araujo da Silva0d1a7d72a1d4
diff --git a/backend/src/services/alert/alert-recipient-resolver.test.ts b/backend/src/services/alert/alert-recipient-resolver.test.tsindex 22456b532c..a35692cb8c 100644--- a/backend/src/services/alert/alert-recipient-resolver.test.ts+++ b/backend/src/services/alert/alert-recipient-resolver.test.ts@@ -37,7 +37,7 @@ const buildResolver = (opts: {const user = (id: string): TUser => ({ id, email: `${id}@example.com`, firstName: id.toUpperCase() });describe("alert recipient resolver — send-time scope re-check", () => {- test("org scope: drops a user no longer in the org, keeps members and raw emails", async () => {+ test("org scope: drops a user no longer in the org, keeps current members", async () => {const resolver = buildResolver({ users: [user("u1"), user("u2")], orgUserIds: ["u1"] });const result = await resolver.resolveMany(@@ -46,8 +46,7 @@ describe("alert recipient resolver — send-time scope re-check", () => {"c1",[{ principalType: AlertPrincipalType.USER, principalId: "u1" },- { principalType: AlertPrincipalType.USER, principalId: "u2" }, // removed from org- { principalType: AlertPrincipalType.EMAIL, principalId: "[email protected]" }+ { principalType: AlertPrincipalType.USER, principalId: "u2" } // removed from org]]]),@@ -55,7 +54,7 @@ describe("alert recipient resolver — send-time scope re-check", () => {);const emails = (result.get("c1") ?? []).map((r) => r.email).sort();- expect(emails).toEqual(["[email protected]", "[email protected]"]);+ expect(emails).toEqual(["[email protected]"]);});test("project scope: drops group members no longer effective in the project", async () => {diff --git a/backend/src/services/alert/alert-recipient-resolver.ts b/backend/src/services/alert/alert-recipient-resolver.tsindex 4599d364ad..8efa750f6d 100644--- a/backend/src/services/alert/alert-recipient-resolver.ts+++ b/backend/src/services/alert/alert-recipient-resolver.ts@@ -81,7 +81,6 @@ export const alertRecipientResolverFactory = ({const result = new Map<string, TAlertRecipient[]>();for (const [channelId, rows] of rowsByChannel.entries()) {const userIds = new Set<string>();- const rawEmails = new Set<string>();for (const recipient of rows) {switch (recipient.principalType) {@@ -91,32 +90,20 @@ export const alertRecipientResolverFactory = ({case AlertPrincipalType.GROUP:(groupMembers.get(recipient.principalId) ?? []).forEach((userId) => userIds.add(userId));break;- case AlertPrincipalType.EMAIL:- rawEmails.add(recipient.principalId.toLowerCase());- break;default:logger.warn(`Unknown alert recipient principal type '${recipient.principalType}'`);}}const resolved: TAlertRecipient[] = [];- const seenEmails = new Set<string>();-userIds.forEach((userId) => {+ // usersById only holds in-scope users, so out-of-scope recipients are skipped here.const user = usersById.get(userId);if (user?.email) {- seenEmails.add(user.email.toLowerCase());resolved.push({ userId: user.id, email: user.email, firstName: user.firstName });}});- rawEmails.forEach((email) => {- if (!seenEmails.has(email)) {- seenEmails.add(email);- resolved.push({ email });- }- });-result.set(channelId, resolved);}diff --git a/backend/src/services/alert/alert-types.ts b/backend/src/services/alert/alert-types.tsindex 6dc9a6a9fb..44de6edb75 100644--- a/backend/src/services/alert/alert-types.ts+++ b/backend/src/services/alert/alert-types.ts@@ -6,8 +6,7 @@ import { TAlertPayload } from "./alert-channel-types";export enum AlertPrincipalType {USER = "user",- GROUP = "group",- EMAIL = "email"+ GROUP = "group"}export enum AlertTriggerType {diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.tsindex 5b360da4ec..b9092e02e1 100644--- a/frontend/src/hooks/api/alerts/types.ts+++ b/frontend/src/hooks/api/alerts/types.ts@@ -19,9 +19,7 @@ export enum AlertChannelType {export enum AlertPrincipalType {User = "user",- Group = "group",- Role = "role",- Email = "email"+ Group = "group"}export enum AlertTimeUnit {@@ -39,10 +37,8 @@ export const ALERT_TIME_UNIT_LABELS: Record<AlertTimeUnit, string> = {};export const ALERT_PRINCIPAL_TYPE_LABELS: Record<AlertPrincipalType, string> = {- [AlertPrincipalType.Email]: "Email",[AlertPrincipalType.User]: "User",- [AlertPrincipalType.Group]: "Group",- [AlertPrincipalType.Role]: "Role"+ [AlertPrincipalType.Group]: "Group"};export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {diff --git a/frontend/src/views/AlertsPage/components/channels/ChannelRecipientsField.tsx b/frontend/src/views/AlertsPage/components/channels/ChannelRecipientsField.tsxindex 819273d49b..3d4f20ace1 100644--- a/frontend/src/views/AlertsPage/components/channels/ChannelRecipientsField.tsx+++ b/frontend/src/views/AlertsPage/components/channels/ChannelRecipientsField.tsx@@ -2,12 +2,12 @@ import { useMemo, useState } from "react";import { Controller, useFormContext } from "react-hook-form";import {- CreatableSelect,Field,FieldContent,FieldDescription,FieldError,- FieldLabel+ FieldLabel,+ FilterableSelect} from "@app/components/v3";import { useOrganization } from "@app/context";import {@@ -19,8 +19,6 @@ import {import { TAlertChannelForm, TAlertChannelRecipientForm } from "@app/hooks/api/alertChannels";import { ALERT_PRINCIPAL_TYPE_LABELS, AlertPrincipalType } from "@app/hooks/api/alerts";-const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;-type RecipientOption = {principalType: AlertPrincipalType;principalId: string;@@ -73,13 +71,6 @@ const RecipientsSelect = ({ userOptions, groupOptions, labelLookup }: PrincipalS);const toOption = (recipient: TAlertChannelRecipientForm): RecipientOption => {- if (recipient.principalType === AlertPrincipalType.Email) {- return {- principalType: AlertPrincipalType.Email,- principalId: recipient.principalId,- label: recipient.principalId- };- }const resolved = labelLookup.get(`${recipient.principalType}:${recipient.principalId}`);return {principalType: recipient.principalType,@@ -101,10 +92,10 @@ const RecipientsSelect = ({ userOptions, groupOptions, labelLookup }: PrincipalS<Field><FieldLabel>Recipients</FieldLabel><FieldContent>- <CreatableSelect+ <FilterableSelectisMulticloseMenuOnSelect={false}- placeholder="Add users, groups, or type an email..."+ placeholder="Add users or groups..."options={inputValue.trim() ? groupedOptions : []}value={value}isError={Boolean(error)}@@ -112,8 +103,8 @@ const RecipientsSelect = ({ userOptions, groupOptions, labelLookup }: PrincipalSonInputChange={(next) => setInputValue(next)}noOptionsMessage={() =>inputValue.trim()- ? "No matches. Type a full email to add it."- : "Type to search users, groups, or an email"+ ? "No matching users or groups"+ : "Type to search users or groups"}getOptionValue={(option: RecipientOption) =>`${option.principalType}:${option.principalId}`@@ -121,15 +112,6 @@ const RecipientsSelect = ({ userOptions, groupOptions, labelLookup }: PrincipalSgetOptionLabel={(option: RecipientOption) =>`${option.label} (${ALERT_PRINCIPAL_TYPE_LABELS[option.principalType]})`}- isValidNewOption={(input) => EMAIL_REGEX.test(input.trim())}- formatCreateLabel={(input) => `Add email "${input.trim()}"`}- getNewOptionData={(input) =>- ({- principalType: AlertPrincipalType.Email,- principalId: input.trim().toLowerCase(),- label: input.trim().toLowerCase()- }) as RecipientOption- }onChange={(newValue) => {field.onChange((newValue as RecipientOption[]).map((option) => ({@@ -141,8 +123,7 @@ const RecipientsSelect = ({ userOptions, groupOptions, labelLookup }: PrincipalS}}/><FieldDescription>- This channel delivers to these recipients. Add users, groups, or raw email- addresses.+ This channel delivers to these recipients. Add users or groups.</FieldDescription><FieldError errors={[error]} /></FieldContent>