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
squash migrations and fix bugs from greptile
adilsoncc8c3baa0446
diff --git a/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.ts b/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.tsnew file mode 100644index 0000000000..5be93b0346--- /dev/null+++ b/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.ts@@ -0,0 +1,35 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ const hasExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "externalEmails");+ const hasAllowExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");++ if (!hasExternalEmails || !hasAllowExternalEmails) {+ await knex.schema.alterTable(TableName.SecretSharing, (t) => {+ if (!hasExternalEmails) {+ t.json("externalEmails").nullable();+ }+ if (!hasAllowExternalEmails) {+ t.boolean("allowExternalEmails").nullable().defaultTo(false);+ }+ });+ }+}++export async function down(knex: Knex): Promise<void> {+ const hasExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "externalEmails");+ const hasAllowExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");++ if (hasExternalEmails || hasAllowExternalEmails) {+ await knex.schema.alterTable(TableName.SecretSharing, (t) => {+ if (hasExternalEmails) {+ t.dropColumn("externalEmails");+ }+ if (hasAllowExternalEmails) {+ t.dropColumn("allowExternalEmails");+ }+ });+ }+}diff --git a/backend/src/db/migrations/20260324200000_secret-sharing-unauthorized-emails.ts b/backend/src/db/migrations/20260324200000_secret-sharing-unauthorized-emails.tsdeleted file mode 100644index 1383f37355..0000000000--- a/backend/src/db/migrations/20260324200000_secret-sharing-unauthorized-emails.ts+++ /dev/null@@ -1,21 +0,0 @@-import { Knex } from "knex";--import { TableName } from "../schemas";--export async function up(knex: Knex): Promise<void> {- const hasColumn = await knex.schema.hasColumn(TableName.SecretSharing, "externalEmails");- if (!hasColumn) {- await knex.schema.alterTable(TableName.SecretSharing, (t) => {- t.json("externalEmails").nullable();- });- }-}--export async function down(knex: Knex): Promise<void> {- const hasColumn = await knex.schema.hasColumn(TableName.SecretSharing, "externalEmails");- if (hasColumn) {- await knex.schema.alterTable(TableName.SecretSharing, (t) => {- t.dropColumn("externalEmails");- });- }-}diff --git a/backend/src/db/migrations/20260324200001_secret-sharing-allow-external-emails.ts b/backend/src/db/migrations/20260324200001_secret-sharing-allow-external-emails.tsdeleted file mode 100644index d7761a395a..0000000000--- a/backend/src/db/migrations/20260324200001_secret-sharing-allow-external-emails.ts+++ /dev/null@@ -1,21 +0,0 @@-import { Knex } from "knex";--import { TableName } from "../schemas";--export async function up(knex: Knex): Promise<void> {- const hasColumn = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");- if (!hasColumn) {- await knex.schema.alterTable(TableName.SecretSharing, (t) => {- t.boolean("allowExternalEmails").nullable().defaultTo(false);- });- }-}--export async function down(knex: Knex): Promise<void> {- const hasColumn = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");- if (hasColumn) {- await knex.schema.alterTable(TableName.SecretSharing, (t) => {- t.dropColumn("allowExternalEmails");- });- }-}diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.tsindex 9425c5216d..a4d33d6746 100644--- a/backend/src/services/secret-sharing/secret-sharing-service.ts+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts@@ -162,10 +162,11 @@ export const secretSharingServiceFactory = ({const authorizedEmails: string[] = [];if (emails && emails.length > 0) {+ const uniqueEmails = [...new Set(emails)];const allOrgMembers = await orgDAL.findAllOrgMembers(orgId);// Check to see that all emails are a part of the organization (if enforced) while also collecting a list of emails which are in the org- for (const email of emails) {+ for (const email of uniqueEmails) {if (allOrgMembers.some((v) => v.user.email === email)) {authorizedEmails.push(email);// If the email is not part of the org, but access type / org settings require it@@ -182,7 +183,7 @@ export const secretSharingServiceFactory = ({}// When non-org emails are present, a password is required so external recipients can authenticate- const externalEmails = emails ? emails.filter((e) => !authorizedEmails.includes(e)) : [];+ const externalEmails = emails ? [...new Set(emails)].filter((e) => !authorizedEmails.includes(e)) : [];if (externalEmails.length > 0 && !password) {throw new BadRequestError({@@ -217,8 +218,8 @@ export const secretSharingServiceFactory = ({const mappedSharedSecret = mapIdentifierToId(newSharedSecret);- // Loop through recipients and send out emails- if (authorizedEmails.length > 0 || externalEmails.length > 0) {+ // Loop through authorized emails to define the display name in email (only for authorized org members)+ if (authorizedEmails.length > 0) {let displayUsername: string | undefined;if (actor === ActorType.USER) {@@ -244,7 +245,7 @@ export const secretSharingServiceFactory = ({for await (const email of allEmails) {try {// Only show the username to emails which are part of the organization- const senderUsername = allEmails.includes(email) ? displayUsername : undefined;+ const senderUsername = authorizedEmails.includes(email) ? displayUsername : undefined;const isExternalEmail = !authorizedEmails.includes(email);await smtpService.sendMail({@@ -565,7 +566,12 @@ export const secretSharingServiceFactory = ({const $isAuthorizedEmailUser = async (sharedSecret: TSecretSharing, actorId?: string): Promise<boolean> => {const hasAuthorizedEmails = sharedSecret.authorizedEmails && (sharedSecret.authorizedEmails as string[]).length > 0;- if (!hasAuthorizedEmails || !actorId) return false;+ if (!hasAuthorizedEmails) {+ // No email restrictions means any authenticated user can access (subject to org restrictions which are checked separately)+ return true;+ }++ if (!actorId) return false;const user = await userDAL.findById(actorId);if (!user || !user.email) return false;diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsxindex 1510cfa091..1ad089ab8f 100644--- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx+++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx@@ -407,7 +407,7 @@ export const ShareSecretForm = ({isOptionalhelperText={isAllowingExternalEmails- ? "All recipients will receive a link and need the password to access the secret. They don't need an Infisical account."+ ? "All recipients will receive a link and need the password to access the secret. They don't need an Infisical account, but a password is mandatory in this case.": "Recipients must have an Infisical account to verify identity"}tooltipText={@@ -418,7 +418,7 @@ export const ShareSecretForm = ({</p><p className="mt-2">{isAllowingExternalEmails- ? "External recipients (not in your organization) will need the password to view the secret. Authorized recipients will be able to view the secret without a password."+ ? "External recipients (not in your organization) will need the password to view the secret. Authorized recipients will also need a password if the secret is password-protected.": "Recipients must have an Infisical account to verify their identity."}</p></>