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
improvements in UI and some bug fixes in secret imports
Matheus Nogueira61afea099872
diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.tsindex 6250b09252..2efbb2c73b 100644--- a/backend/src/server/routes/v1/dashboard-router.ts+++ b/backend/src/server/routes/v1/dashboard-router.ts@@ -152,7 +152,13 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {.optional(),imports: SecretImportsSchema.omit({ importEnv: true }).extend({- importEnv: z.object({ name: z.string(), slug: z.string(), id: z.string() }),+ importEnv: z.object({+ name: z.string(),+ slug: z.string(),+ id: z.string(),+ projectId: z.string().optional()+ }),+ sourceProjectName: z.string().optional(),environment: z.string()}).array()@@ -711,7 +717,13 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {200: z.object({imports: SecretImportsSchema.omit({ importEnv: true }).extend({- importEnv: z.object({ name: z.string(), slug: z.string(), id: z.string() })+ importEnv: z.object({+ name: z.string(),+ slug: z.string(),+ id: z.string(),+ projectId: z.string().optional()+ }),+ sourceProjectName: z.string().optional()}).array().optional(),@@ -1644,6 +1656,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {environment: z.string().trim(),secretPath: z.string().trim().default("/").transform(removeTrailingSlash),secretKey: z.string().trim(),+ sourceProjectId: z.string().trim().optional(),isOverride: z.enum(["true", "false"]).transform((value) => value === "true")@@ -1658,7 +1671,23 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {},onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {- const { secretPath, projectId, environment, secretKey, isOverride } = req.query;+ const { secretPath, projectId, environment, secretKey, isOverride, sourceProjectId } = req.query;++ if (sourceProjectId && sourceProjectId !== projectId) {+ const { value } = await server.services.secretImport.getCrossProjectImportSecretValue({+ actorId: req.permission.id,+ actor: req.permission.type,+ actorAuthMethod: req.permission.authMethod,+ actorOrgId: req.permission.orgId,+ projectId,+ sourceProjectId,+ environment,+ secretPath,+ secretName: secretKey+ });++ return { value };+ }const secret = await server.services.secret.getSecretByNameRaw({actorId: req.permission.id,diff --git a/backend/src/server/routes/v2/secret-import-router.ts b/backend/src/server/routes/v2/secret-import-router.tsindex d956f0e0f5..3e89014e80 100644--- a/backend/src/server/routes/v2/secret-import-router.ts+++ b/backend/src/server/routes/v2/secret-import-router.ts@@ -328,7 +328,13 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>message: z.string(),secretImports: SecretImportsSchema.omit({ importEnv: true }).extend({- importEnv: z.object({ name: z.string(), slug: z.string(), id: z.string() })+ importEnv: z.object({+ name: z.string(),+ slug: z.string(),+ id: z.string(),+ projectId: z.string().optional()+ }),+ sourceProjectName: z.string().optional()}).array()})diff --git a/backend/src/services/secret-import/secret-import-dal.ts b/backend/src/services/secret-import/secret-import-dal.tsindex c58345e095..d785ec3e73 100644--- a/backend/src/services/secret-import/secret-import-dal.ts+++ b/backend/src/services/secret-import/secret-import-dal.ts@@ -91,13 +91,15 @@ export const secretImportDALFactory = (db: TDbClient) => {}}).join(TableName.Environment, `${TableName.SecretImport}.importEnv`, `${TableName.Environment}.id`)+ .leftJoin(`${TableName.Project} as sourceProject`, `${TableName.Environment}.projectId`, `sourceProject.id`).whereNull(`${TableName.Environment}.deleteAfter`).select(db.ref("*").withSchema(TableName.SecretImport) as unknown as keyof TSecretImports,db.ref("slug").withSchema(TableName.Environment),db.ref("name").withSchema(TableName.Environment),db.ref("id").withSchema(TableName.Environment).as("envId"),- db.ref("projectId").withSchema(TableName.Environment).as("envProjectId")+ db.ref("projectId").withSchema(TableName.Environment).as("envProjectId"),+ db.raw(`"sourceProject"."name" as "sourceProjectName"`)).orderBy("position", "asc");@@ -107,9 +109,10 @@ export const secretImportDALFactory = (db: TDbClient) => {const docs = await query;- return docs.map(({ envId, envProjectId, slug, name, ...el }) => ({+ return docs.map(({ envId, envProjectId, slug, name, sourceProjectName, ...el }) => ({...el,- importEnv: { id: envId, slug, name, projectId: envProjectId }+ importEnv: { id: envId, slug, name, projectId: envProjectId },+ sourceProjectName: (sourceProjectName as string) ?? undefined}));} catch (error) {throw new DatabaseError({ error, name: "Find secret imports" });@@ -121,13 +124,15 @@ export const secretImportDALFactory = (db: TDbClient) => {const doc = await (tx || db.replicaNode())(TableName.SecretImport).where({ [`${TableName.SecretImport}.id` as "id"]: id }).join(TableName.Environment, `${TableName.SecretImport}.importEnv`, `${TableName.Environment}.id`)+ .leftJoin(`${TableName.Project} as sourceProject`, `${TableName.Environment}.projectId`, `sourceProject.id`).whereNull(`${TableName.Environment}.deleteAfter`).select(db.ref("*").withSchema(TableName.SecretImport) as unknown as keyof TSecretImports,db.ref("slug").withSchema(TableName.Environment),db.ref("name").withSchema(TableName.Environment),db.ref("id").withSchema(TableName.Environment).as("envId"),- db.ref("projectId").withSchema(TableName.Environment).as("envProjectId")+ db.ref("projectId").withSchema(TableName.Environment).as("envProjectId"),+ db.raw(`"sourceProject"."name" as "sourceProjectName"`)).first();@@ -135,11 +140,12 @@ export const secretImportDALFactory = (db: TDbClient) => {return null;}- const { envId, envProjectId, slug, name, ...el } = doc;+ const { envId, envProjectId, slug, name, sourceProjectName, ...el } = doc;return {...el,- importEnv: { id: envId, slug, name, projectId: envProjectId }+ importEnv: { id: envId, slug, name, projectId: envProjectId },+ sourceProjectName: (sourceProjectName as string) ?? undefined};} catch (error) {throw new DatabaseError({ error, name: "Find secret imports" });diff --git a/backend/src/services/secret-import/secret-import-service.ts b/backend/src/services/secret-import/secret-import-service.tsindex 28811faa20..abebf25354 100644--- a/backend/src/services/secret-import/secret-import-service.ts+++ b/backend/src/services/secret-import/secret-import-service.ts@@ -35,6 +35,7 @@ import { fnSecretsFromImports, fnSecretsV2FromImports } from "./secret-import-fnimport {TCreateSecretImportDTO,TDeleteSecretImportDTO,+ TGetCrossProjectImportSecretValueDTO,TGetSecretImportByIdDTO,TGetSecretImportsDTO,TGetSecretsFromImportDTO,@@ -50,7 +51,7 @@ type TSecretImportServiceFactoryDep = {projectBotService: Pick<TProjectBotServiceFactory, "getBotKey">;projectDAL: Pick<TProjectDALFactory, "checkProjectUpgradeStatus">;projectEnvDAL: TProjectEnvDALFactory;- projectGrantDAL: Pick<TProjectGrantDALFactory, "findOne">;+ projectGrantDAL: Pick<TProjectGrantDALFactory, "findOne" | "find">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;secretQueueService: Pick<TSecretQueueFactory, "syncSecrets" | "replicateSecrets">;licenseService: Pick<TLicenseServiceFactory, "getPlan">;@@ -1046,6 +1047,62 @@ export const secretImportServiceFactory = ({return result;};+ const getCrossProjectImportSecretValue = async ({+ projectId,+ sourceProjectId,+ environment,+ secretPath,+ secretName,+ actorId,+ actor,+ actorAuthMethod,+ actorOrgId+ }: TGetCrossProjectImportSecretValueDTO) => {+ await permissionService.getProjectPermission({+ actor,+ actorId,+ projectId,+ actorAuthMethod,+ actorOrgId,+ actionProjectType: ActionProjectType.SecretManager+ });++ const sourceFolder = await folderDAL.findBySecretPath(sourceProjectId, environment, secretPath);+ if (!sourceFolder)+ throw new NotFoundError({+ message: `Folder not found at path '${secretPath}' in environment '${environment}' of source project`+ });++ const grant = await projectGrantDAL.findOne({+ sourceFolderId: sourceFolder.id,+ targetProjectId: projectId+ });+ if (!grant)+ throw new ForbiddenRequestError({ message: "No cross-project grant found authorizing this import" });++ const { shouldUseSecretV2Bridge } = await projectBotService.getBotKey(sourceProjectId);+ if (!shouldUseSecretV2Bridge)+ throw new BadRequestError({ message: "Source project has not been upgraded to the latest version" });++ const { decryptor: sourceDecryptor } = await kmsService.createCipherPairWithDataKey({+ type: KmsDataKey.SecretManager,+ projectId: sourceProjectId+ });++ const secrets = await secretV2BridgeDAL.find(+ { folderId: sourceFolder.id, [`${TableName.SecretV2}.key` as "key"]: secretName },+ { limit: 1 }+ );+ if (!secrets.length)+ throw new NotFoundError({ message: `Secret '${secretName}' not found in source project` });++ const secretValue = secrets[0].encryptedValue+ ? sourceDecryptor({ cipherTextBlob: secrets[0].encryptedValue }).toString()+ : "";++ return { value: secretValue };+ };+return {createImport,updateImport,@@ -1059,6 +1116,7 @@ export const secretImportServiceFactory = ({fnSecretsFromImports,getProjectImportMultiEnvCount,getImportsMultiEnv,- getFolderIsImportedBy+ getFolderIsImportedBy,+ getCrossProjectImportSecretValue};};diff --git a/backend/src/services/secret-import/secret-import-types.ts b/backend/src/services/secret-import/secret-import-types.tsindex 4280edabb4..745d80e905 100644--- a/backend/src/services/secret-import/secret-import-types.ts+++ b/backend/src/services/secret-import/secret-import-types.ts@@ -47,6 +47,13 @@ export type TGetSecretsFromImportDTO = {path: string;} & TProjectPermission;+export type TGetCrossProjectImportSecretValueDTO = {+ sourceProjectId: string;+ environment: string;+ secretPath: string;+ secretName: string;+} & TProjectPermission;+export type FolderResult = {envName: string;folderName: string;diff --git a/frontend/src/hooks/api/dashboard/types.ts b/frontend/src/hooks/api/dashboard/types.tsindex f6aa986d96..ac412da0e1 100644--- a/frontend/src/hooks/api/dashboard/types.ts+++ b/frontend/src/hooks/api/dashboard/types.ts@@ -171,6 +171,7 @@ export type TGetSecretValueDTO = {environment: string;secretPath: string;isOverride?: boolean;+ sourceProjectId?: string;};export type DashboardSecretValue =diff --git a/frontend/src/hooks/api/secretImports/types.ts b/frontend/src/hooks/api/secretImports/types.tsindex 8f3c33b385..c5d191009c 100644--- a/frontend/src/hooks/api/secretImports/types.ts+++ b/frontend/src/hooks/api/secretImports/types.ts@@ -5,7 +5,7 @@ export type TSecretImport = {id: string;folderId: string;importPath: string;- importEnv: ProjectEnv;+ importEnv: ProjectEnv & { projectId?: string };position: string;createdAt: string;updatedAt: string;@@ -15,6 +15,7 @@ export type TSecretImport = {replicationStatus?: string;lastReplicated?: string;environment?: string;+ sourceProjectName?: string;};export type TGetImportedFoldersByEnvDTO = {diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretRow.tsxindex 5c6791f3aa..1d041d5c64 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretRow.tsx@@ -10,6 +10,7 @@ type Props = {secretPath?: string;isEmpty?: boolean;missingFromEnvs?: string[];+ sourceProjectId?: string;};export const SecretImportSecretRow = ({@@ -17,7 +18,8 @@ export const SecretImportSecretRow = ({environment,secretPath = "/",isEmpty,- missingFromEnvs+ missingFromEnvs,+ sourceProjectId}: Props) => {return (<TableRow className="group">@@ -40,6 +42,7 @@ export const SecretImportSecretRow = ({environment={environment}secretPath={secretPath}isEmpty={isEmpty}+ sourceProjectId={sourceProjectId}/></TableCell></TableRow>diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretValueCell.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretValueCell.tsxindex 35cc603e7b..0703d7ff2f 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretValueCell.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportSecretValueCell.tsx@@ -14,13 +14,15 @@ type Props = {environment: string;secretPath?: string;isEmpty?: boolean;+ sourceProjectId?: string;};export const SecretImportSecretValueCell = ({secretKey,environment,secretPath = "/",- isEmpty+ isEmpty,+ sourceProjectId}: Props) => {const [isFieldFocused, setIsFieldFocused] = useToggle();const [isCopied, , setIsCopied] = useTimedReset<boolean>({ initialState: false });@@ -38,7 +40,8 @@ export const SecretImportSecretValueCell = ({environment,secretPath,secretKey,- projectId: currentProject.id+ projectId: currentProject.id,+ sourceProjectId},{enabled: isFieldFocused && canFetchSecretValuediff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsxindex ebc4930ac3..6b9072465f 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx@@ -496,6 +496,11 @@ export const SecretImportTableRow = ({: importPath}isEmpty={secret.isEmpty}+ sourceProjectId={+ selectedEnvImportData?.secretImportRecord?.importEnv?.projectId !== currentProject?.id+ ? selectedEnvImportData?.secretImportRecord?.importEnv?.projectId+ : undefined+ }/>))}</TableBody>@@ -551,6 +556,11 @@ export const SecretImportTableRow = ({secretPath={importPath}isEmpty={secret.isEmpty}missingFromEnvs={missingEnvNames}+ sourceProjectId={+ secretImport?.importEnv?.projectId !== currentProject?.id+ ? secretImport?.importEnv?.projectId+ : undefined+ }/>);})}@@ -606,6 +616,11 @@ export const SecretImportTableRow = ({: importPath}isEmpty={secret.isEmpty}+ sourceProjectId={+ singleEnvImport?.importEnv?.projectId !== currentProject?.id+ ? singleEnvImport?.importEnv?.projectId+ : undefined+ }/>))}</TableBody>@@ -657,6 +672,11 @@ export const SecretImportTableRow = ({><div className="relative flex w-full items-center"><div className="flex items-center gap-2 overflow-hidden">+ {secretImport?.sourceProjectName &&+ secretImport.importEnv.projectId &&+ secretImport.importEnv.projectId !== currentProject?.id && (+ <Badge variant="warning">{secretImport.sourceProjectName}</Badge>+ )}<Badge variant="neutral"><LayersIcon />{importEnvName}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateSecretImportForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateSecretImportForm.tsxindex 67d38fcaf5..5fa85897a0 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateSecretImportForm.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateSecretImportForm.tsx@@ -445,7 +445,7 @@ export const CreateSecretImportForm = ({type="button"variant="project"isDisabled={!selectedGrant}- isLoading={isCreatingImport}+ isPending={isCreatingImport}onClick={async () => {if (!selectedGrant) return;try {diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsxindex 6a127d6b5e..dd35df7016 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx@@ -169,6 +169,13 @@ export const SecretImportItem = ({secretPath={secretImport?.importPath || ""}// isReplication={isReplication}/>+ {secretImport?.sourceProjectName &&+ importEnv.projectId &&+ importEnv.projectId !== currentProject?.id && (+ <span className="ml-2 rounded border border-yellow-700/40 bg-yellow-900/20 px-1.5 py-0.5 text-xs text-yellow-400">+ {secretImport.sourceProjectName}+ </span>+ )}</div><div className="flex items-center space-x-4 py-2 pr-4">{lastReplicated && (@@ -317,6 +324,9 @@ export const SecretImportItem = ({<SecretImportSecretRowsecret={secret}key={`${id}-${secret.key}-${index + 1}`}+ sourceProjectId={+ importEnv.projectId !== currentProject?.id ? importEnv.projectId : undefined+ }/>))}</tbody>diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportSecretRow.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportSecretRow.tsxindex fd8c8a4403..ff4c02b645 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportSecretRow.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportSecretRow.tsx@@ -13,10 +13,12 @@ type SecretImportSecretRowProps = {isEmpty?: boolean;overridden: { env: string; secretPath: string };};+ sourceProjectId?: string;};export const SecretImportSecretRow = ({- secret: { key, environment, secretPath = "/", isEmpty }+ secret: { key, environment, secretPath = "/", isEmpty },+ sourceProjectId}: SecretImportSecretRowProps) => {const [isFieldFocused, setIsFieldFocused] = useToggle();@@ -33,7 +35,8 @@ export const SecretImportSecretRow = ({environment,secretPath,secretKey: key,- projectId: currentProject.id+ projectId: currentProject.id,+ sourceProjectId},{enabled: isFieldFocused && canFetchSecretValue