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
remove the migration that stores external users
adilson46f000f23084
diff --git a/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.ts b/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.tsdeleted file mode 100644index 5be93b0346..0000000000--- a/backend/src/db/migrations/20260324200000_secret-sharing-external-emails.ts+++ /dev/null@@ -1,35 +0,0 @@-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/20260325200000_secret-sharing-allow-external-emails.ts b/backend/src/db/migrations/20260325200000_secret-sharing-allow-external-emails.tsnew file mode 100644index 0000000000..f61fb37f50--- /dev/null+++ b/backend/src/db/migrations/20260325200000_secret-sharing-allow-external-emails.ts@@ -0,0 +1,23 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ const hasAllowExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");++ if (!hasAllowExternalEmails) {+ await knex.schema.alterTable(TableName.SecretSharing, (t) => {+ t.boolean("allowExternalEmails").nullable().defaultTo(false);+ });+ }+}++export async function down(knex: Knex): Promise<void> {+ const hasAllowExternalEmails = await knex.schema.hasColumn(TableName.SecretSharing, "allowExternalEmails");++ if (hasAllowExternalEmails) {+ await knex.schema.alterTable(TableName.SecretSharing, (t) => {+ t.dropColumn("allowExternalEmails");+ });+ }+}diff --git a/backend/src/db/schemas/secret-sharing.ts b/backend/src/db/schemas/secret-sharing.tsindex fbdf3b7761..be2fdfc1ea 100644--- a/backend/src/db/schemas/secret-sharing.ts+++ b/backend/src/db/schemas/secret-sharing.ts@@ -30,7 +30,6 @@ export const SecretSharingSchema = z.object({type: z.string().default("share"),authorizedEmails: z.unknown().nullable().optional(),identityId: z.string().uuid().nullable().optional(),- externalEmails: z.unknown().nullable().optional(),allowExternalEmails: z.boolean().default(false).nullable().optional()});diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 436401ad8e..debe6e43d2 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3516,9 +3516,9 @@ export const SECRET_SHARING = {accessType:"Determines who can access the shared secret. 'organization' restricts access to users within your organization. 'anyone' allows access to anyone with the link. Defaults to 'organization'.",authorizedEmails:- "An optional array of email addresses that are authorized to view this secret. Only users with these email addresses will be able to access the secret. Maximum 100 emails.",+ "An optional array of email addresses to share the secret with. Maximum 100 emails. Organization members in the list get direct access. When allowExternalEmails is enabled, non-member emails are also accepted and recipients will receive the secret link via email, but must use the password to access it.",allowExternalEmails:- "When true, emails not belonging to organization members are allowed. External recipients will receive the secret link via email and must use the password to access it."+ "When true, non-organization-member emails are allowed in the authorizedEmails list. A password is required when this option is enabled. External recipients will receive the secret link via email and must use the password to access it."},DELETE: {id: "The ID of the shared secret to delete."diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.tsindex 45c8850e99..b948962c89 100644--- a/backend/src/server/routes/v1/secret-sharing-router.ts+++ b/backend/src/server/routes/v1/secret-sharing-router.ts@@ -105,7 +105,6 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>)}).omit({authorizedEmails: true,- externalEmails: true,allowExternalEmails: true})}@@ -273,7 +272,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>.nativeEnum(SecretSharingAccessType).default(SecretSharingAccessType.Organization).describe(SECRET_SHARING.CREATE.accessType),- emails: z+ authorizedEmails: z.string().email().array()@@ -310,11 +309,11 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>});}- if (data.allowExternalEmails && (!data.emails || data.emails.length === 0)) {+ if (data.allowExternalEmails && (!data.authorizedEmails || data.authorizedEmails.length === 0)) {ctx.addIssue({code: z.ZodIssueCode.custom,message: "Emails are required when allowing external emails",- path: ["emails"]+ path: ["authorizedEmails"]});}@@ -334,13 +333,15 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>},onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {+ const { authorizedEmails, ...restBody } = req.body;const sharedSecret = await req.server.services.secretSharing.createSharedSecret({actor: req.permission.type,actorId: req.permission.id,orgId: req.permission.orgId,actorAuthMethod: req.permission.authMethod,actorOrgId: req.permission.orgId,- ...req.body+ ...restBody,+ emails: authorizedEmails});await server.services.auditLog.createAuditLog({diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.tsindex a4d33d6746..541e58dae3 100644--- a/backend/src/services/secret-sharing/secret-sharing-service.ts+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts@@ -159,17 +159,16 @@ export const secretSharingServiceFactory = ({const encryptWithRoot = kmsService.encryptWithRootKey();- const authorizedEmails: string[] = [];+ const orgMemberEmails: 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 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+ for (const email of emails) {+ const isOrgMember = allOrgMembers.some((v) => v.user.email === email);++ if (isOrgMember) {+ orgMemberEmails.push(email);} else if (!allowExternalEmails ||!rootOrg.allowSecretSharingOutsideOrganization ||@@ -182,10 +181,9 @@ export const secretSharingServiceFactory = ({}}- // When non-org emails are present, a password is required so external recipients can authenticate- const externalEmails = emails ? [...new Set(emails)].filter((e) => !authorizedEmails.includes(e)) : [];-- if (externalEmails.length > 0 && !password) {+ // When external emails are allowed, a password is required so external recipients can authenticate+ // const hasExternalEmails = emails && emails.length > orgMemberEmails.length;+ if (allowExternalEmails && !password) {throw new BadRequestError({message: "A password is required when sharing secrets with users outside your organization"});@@ -196,6 +194,8 @@ export const secretSharingServiceFactory = ({const id = crypto.randomBytes(32).toString("hex");const hashedPassword = password ? await crypto.hashing().createHash(password, appCfg.SALT_ROUNDS) : null;+ // When allowExternalEmails is true, don't store any emails — access is password-based only.+ // When allowExternalEmails is false, store org member emails for access control.const newSharedSecret = await secretSharingDAL.create({identifier: id,iv: null,@@ -211,15 +211,14 @@ export const secretSharingServiceFactory = ({...(actor === ActorType.IDENTITY && { identityId: actorId }),orgId,accessType,- authorizedEmails: authorizedEmails.length > 0 ? JSON.stringify(authorizedEmails) : undefined,- externalEmails: externalEmails.length > 0 ? JSON.stringify(externalEmails) : undefined,+ authorizedEmails: orgMemberEmails.length > 0 ? JSON.stringify(orgMemberEmails) : undefined,allowExternalEmails: Boolean(allowExternalEmails)});const mappedSharedSecret = mapIdentifierToId(newSharedSecret);- // Loop through authorized emails to define the display name in email (only for authorized org members)- if (authorizedEmails.length > 0) {+ // Loop through emails to define the display name in email (only for authorized org members)+ if (emails && emails.length > 0) {let displayUsername: string | undefined;if (actor === ActorType.USER) {@@ -240,22 +239,18 @@ export const secretSharingServiceFactory = ({displayUsername = `${identity.name} (Machine Identity)`;}- const allEmails = [...new Set([...authorizedEmails, ...externalEmails])];-- for await (const email of allEmails) {+ for await (const email of emails) {try {- // Only show the username to emails which are part of the organization- const senderUsername = authorizedEmails.includes(email) ? displayUsername : undefined;- const isExternalEmail = !authorizedEmails.includes(email);+ const isOrgMember = orgMemberEmails.includes(email);await smtpService.sendMail({recipients: [email],subjectLine: "A secret has been shared with you",substitutions: {name,- senderUsername,+ senderUsername: isOrgMember ? displayUsername : undefined,secretRequestUrl: `${appCfg.SITE_URL}/shared/secret/${mappedSharedSecret.id}`,- isPasswordProtected: isExternalEmail && Boolean(password) // password protected is only necessary for external users+ isPasswordProtected: allowExternalEmails && Boolean(password) // if allow external emails, all secrets are password protected},template: SmtpTemplates.SecretRequestCompleted});@@ -580,10 +575,6 @@ export const secretSharingServiceFactory = ({};// Checks whether external (non-org) email access is available for this secret.- const $hasExternalEmailAccess = (sharedSecret: TSecretSharing): boolean => {- const hasExternalEmails = sharedSecret.externalEmails && (sharedSecret.externalEmails as string[]).length > 0;- return Boolean(hasExternalEmails && sharedSecret.allowExternalEmails);- };const getSharedSecretById = async (sharedSecretId: string, orgId?: string, actorId?: string) => {const sharedSecret = await secretSharingDAL.findOne({@@ -621,7 +612,7 @@ export const secretSharingServiceFactory = ({const isAuthorizedUser = await $isAuthorizedEmailUser(sharedSecret, actorId);- if (!isAuthorizedUser && !$hasExternalEmailAccess(sharedSecret)) {+ if (!isAuthorizedUser && !sharedSecret.allowExternalEmails) {if (!actorId) {throw new UnauthorizedError({ message: "Authentication required to view this secret" });}@@ -676,7 +667,7 @@ export const secretSharingServiceFactory = ({const isAuthorizedUser = await $isAuthorizedEmailUser(sharedSecret, actorId);- if (!isAuthorizedUser && !$hasExternalEmailAccess(sharedSecret)) {+ if (!isAuthorizedUser && !sharedSecret.allowExternalEmails) {if (!actorId) {throw new UnauthorizedError();}diff --git a/docs/documentation/platform/secret-sharing.mdx b/docs/documentation/platform/secret-sharing.mdxindex 9a7e5b965d..76e842d706 100644--- a/docs/documentation/platform/secret-sharing.mdx+++ b/docs/documentation/platform/secret-sharing.mdx@@ -24,8 +24,8 @@ Infisical offers a secure solution for sharing secrets over the internet in a ti- **Expires In:** The time it'll take for the secret to expire.- **Max Views:** How many times the secret can be viewed before it's destroyed.- - **Emails (optional):** Emails which are authorized to view this secret. Enabling this feature requires secret viewers to log into Infisical. Each email will receive the shared secret link in their inbox after creation.- - **Allow external recipients (optional):** When enabled, emails not belonging to organization members can receive the shared secret link. External recipients will need the password to access the secret.+ - **Emails (optional):** Email addresses to share the secret with. Each recipient will receive the shared secret link in their inbox after creation. When the "Allow external recipients" toggle is off, only organization member emails are accepted and recipients must have an Infisical account to verify their identity.+ - **Allow external recipients (optional):** When enabled, any email address can be added as a recipient — not just organization members. A password becomes mandatory in this case. All recipients (including external ones) will receive the secret link via email and must use the password to access the secret. This toggle is automatically disabled when "Limit access to people within organization" is enabled.</Step><Step title="Copy Link and Share Secret">After creating the shared secret, its link will be displayed. Share this with the intended recipients.diff --git a/frontend/src/hooks/api/secretSharing/types.ts b/frontend/src/hooks/api/secretSharing/types.tsindex d0cfb2302a..926871ff40 100644--- a/frontend/src/hooks/api/secretSharing/types.ts+++ b/frontend/src/hooks/api/secretSharing/types.ts@@ -32,7 +32,7 @@ export type TCreateSharedSecretRequest = {expiresIn: string;maxViews?: number;accessType?: SecretSharingAccessType;- emails?: string[];+ authorizedEmails?: string[];allowExternalEmails?: boolean;};diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsxindex 1ad089ab8f..0582b6558e 100644--- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx+++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx@@ -149,7 +149,7 @@ export const ShareSecretForm = ({expiresIn,maxViews: shouldLimitView ? Number(viewLimit) : undefined,accessType: formAccessType,- emails: processedEmails,+ authorizedEmails: processedEmails,allowExternalEmails});