Skip to content

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

feat(backend): Doppler in-platform migration and vault config filtering

Igor Correa3b8e57234a14
diff --git a/backend/src/server/routes/v3/external-migration-router.ts b/backend/src/server/routes/v3/external-migration-router.ts
index c44ecb4b18..bb1fd0da1e 100644
--- a/backend/src/server/routes/v3/external-migration-router.ts
+++ b/backend/src/server/routes/v3/external-migration-router.ts
@@ -639,4 +639,198 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider
return { roles };
}
});
+
+ // ─── Doppler In-Platform Migration Routes ────────────────────────────────────
+
+ server.route({
+ method: "GET",
+ url: "/doppler/configs",
+ config: { rateLimit: readLimit },
+ schema: {
+ operationId: "getDopplerExternalMigrationConfigsV3",
+ response: {
+ 200: z.object({
+ configs: z
+ .object({
+ id: z.string(),
+ orgId: z.string(),
+ connectionId: z.string().nullish(),
+ provider: z.string(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+ })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const configs = await server.services.migration.getDopplerExternalMigrationConfigs(req.permission);
+ return { configs };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/doppler/configs",
+ config: { rateLimit: writeLimit },
+ schema: {
+ operationId: "createDopplerExternalMigrationV3",
+ body: z.object({
+ connectionId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ config: z.object({
+ id: z.string(),
+ orgId: z.string(),
+ connectionId: z.string().nullish(),
+ provider: z.string(),
+ createdAt: z.date(),
+ updatedAt: z.date()
+ })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const config = await server.services.migration.createDopplerExternalMigration({
+ connectionId: req.body.connectionId,
+ actor: req.permission
+ });
+ return { config };
+ }
+ });
+
+ server.route({
+ method: "PUT",
+ url: "/doppler/configs/:id",
+ config: { rateLimit: writeLimit },
+ schema: {
+ operationId: "updateDopplerExternalMigrationV3",
+ params: z.object({ id: z.string().uuid() }),
+ body: z.object({
+ connectionId: z.string().uuid().nullable()
+ })
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const config = await server.services.migration.updateDopplerExternalMigration({
+ id: req.params.id,
+ connectionId: req.body.connectionId,
+ actor: req.permission
+ });
+ return { config };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/doppler/configs/:id",
+ config: { rateLimit: writeLimit },
+ schema: {
+ operationId: "deleteDopplerExternalMigrationV3",
+ params: z.object({ id: z.string().uuid() })
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const config = await server.services.migration.deleteDopplerExternalMigration({
+ id: req.params.id,
+ actor: req.permission
+ });
+ return { config };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/doppler/projects",
+ config: { rateLimit: readLimit },
+ schema: {
+ operationId: "getDopplerProjectsV3",
+ querystring: z.object({ configId: z.string().uuid() }),
+ response: {
+ 200: z.object({
+ projects: z
+ .object({
+ id: z.string(),
+ slug: z.string(),
+ name: z.string(),
+ description: z.string()
+ })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const projects = await server.services.migration.getDopplerProjects({
+ configId: req.query.configId,
+ actor: req.permission
+ });
+ return { projects };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/doppler/environments",
+ config: { rateLimit: readLimit },
+ schema: {
+ operationId: "getDopplerEnvironmentsV3",
+ querystring: z.object({
+ configId: z.string().uuid(),
+ projectSlug: z.string().min(1)
+ }),
+ response: {
+ 200: z.object({
+ environments: z
+ .object({
+ id: z.string(),
+ slug: z.string(),
+ name: z.string(),
+ project: z.string()
+ })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const environments = await server.services.migration.getDopplerEnvironments({
+ configId: req.query.configId,
+ projectSlug: req.query.projectSlug,
+ actor: req.permission
+ });
+ return { environments };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/doppler/import-secrets",
+ config: { rateLimit: writeLimit },
+ schema: {
+ operationId: "importDopplerSecretsV3",
+ body: z.object({
+ configId: z.string().uuid(),
+ dopplerProject: z.string().min(1),
+ dopplerEnvironment: z.string().min(1),
+ targetProjectId: z.string().min(1),
+ targetEnvironment: z.string().min(1),
+ targetSecretPath: z.string().min(1).default("/")
+ }),
+ response: {
+ 200: z.object({ imported: z.number() })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const result = await server.services.migration.importDopplerSecrets({
+ ...req.body,
+ actor: req.permission
+ });
+ return result;
+ }
+ });
};
diff --git a/backend/src/services/external-migration/external-migration-fns/doppler.ts b/backend/src/services/external-migration/external-migration-fns/doppler.ts
new file mode 100644
index 0000000000..8cd2c93a8d
--- /dev/null
+++ b/backend/src/services/external-migration/external-migration-fns/doppler.ts
@@ -0,0 +1,3 @@
+// Re-export Doppler API helpers for use in the migration service.
+// The actual implementation lives in the Doppler AppConnection package.
+export { getDopplerSecrets, listDopplerEnvironments, listDopplerProjects } from "@app/services/app-connection/doppler/doppler-connection-fns";
diff --git a/backend/src/services/external-migration/external-migration-fns/index.ts b/backend/src/services/external-migration/external-migration-fns/index.ts
index 4af82bf228..a7e60cabc4 100644
--- a/backend/src/services/external-migration/external-migration-fns/index.ts
+++ b/backend/src/services/external-migration/external-migration-fns/index.ts
@@ -1,3 +1,4 @@
+export * from "./doppler";
export * from "./envkey";
export * from "./import";
export * from "./vault";
diff --git a/backend/src/services/external-migration/external-migration-service.ts b/backend/src/services/external-migration/external-migration-service.ts
index 0a3d4766f1..956f77fe9b 100644
--- a/backend/src/services/external-migration/external-migration-service.ts
+++ b/backend/src/services/external-migration/external-migration-service.ts
@@ -18,6 +18,7 @@ import { OrgServiceActor } from "@app/lib/types";
import { AppConnection } from "../app-connection/app-connection-enums";
import { decryptAppConnectionCredentials } from "../app-connection/app-connection-fns";
import { TAppConnectionServiceFactory } from "../app-connection/app-connection-service";
+import { TDopplerConnection } from "../app-connection/doppler";
import {
convertVaultValueToString,
getHCVaultAuthMounts,
@@ -41,7 +42,10 @@ import { SecretProtectionType } from "../secret/secret-types";
import { TUserDALFactory } from "../user/user-dal";
import {
decryptEnvKeyDataFn,
+ getDopplerSecrets,
importVaultDataFn,
+ listDopplerEnvironments,
+ listDopplerProjects,
parseEnvKeyDataFn,
vaultMigrationTransformMappings
} from "./external-migration-fns";
@@ -49,11 +53,15 @@ import { TExternalMigrationQueueFactory } from "./external-migration-queue";
import {
ExternalMigrationProviders,
ExternalPlatforms,
+ TCreateDopplerExternalMigrationDTO,
TCreateVaultExternalMigrationDTO,
+ TDeleteDopplerExternalMigrationDTO,
TDeleteVaultExternalMigrationDTO,
THasCustomVaultMigrationDTO,
+ TImportDopplerSecretsDTO,
TImportEnvKeyDataDTO,
TImportVaultDataDTO,
+ TUpdateDopplerExternalMigrationDTO,
TUpdateVaultExternalMigrationDTO,
VaultImportStatus
} from "./external-migration-types";
@@ -67,7 +75,7 @@ type TExternalMigrationServiceFactoryDep = {
appConnectionService: Pick<TAppConnectionServiceFactory, "connectAppConnectionById">;
vaultExternalMigrationConfigDAL: Pick<
TVaultExternalMigrationConfigDALFactory,
- "create" | "findOne" | "transaction" | "find" | "updateById" | "deleteById" | "findById"
+ "create" | "findOne" | "transaction" | "find" | "updateById" | "deleteById" | "findById" | "findWithConnection"
>;
userDAL: Pick<TUserDALFactory, "findById">;
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;
@@ -155,7 +163,8 @@ export const externalMigrationServiceFactory = ({
const vaultConfig = await vaultExternalMigrationConfigDAL.findOne({
orgId: actor.orgId,
- namespace
+ namespace,
+ provider: ExternalMigrationProviders.Vault
});
if (!vaultConfig) {
@@ -385,7 +394,8 @@ export const externalMigrationServiceFactory = ({
const config = await vaultExternalMigrationConfigDAL.create({
namespace,
connectionId,
- orgId: actor.orgId
+ orgId: actor.orgId,
+ provider: ExternalMigrationProviders.Vault
});
return config;
@@ -422,6 +432,14 @@ export const externalMigrationServiceFactory = ({
throw new ForbiddenRequestError({ message: "Only admins can update vault external migration" });
}
+ const existing = await vaultExternalMigrationConfigDAL.findById(id);
+ if (!existing || existing.orgId !== actor.orgId) {
+ throw new NotFoundError({ message: "Vault migration config not found" });
+ }
+ if (existing.provider !== ExternalMigrationProviders.Vault) {
+ throw new NotFoundError({ message: "Vault migration config not found" });
+ }
+
if (connectionId) {
const connection = await appConnectionService.connectAppConnectionById<THCVaultConnection>(
AppConnection.HCVault,
@@ -458,7 +476,8 @@ export const externalMigrationServiceFactory = ({
}
const configs = await vaultExternalMigrationConfigDAL.find({
- orgId: actor.orgId
+ orgId: actor.orgId,
+ provider: ExternalMigrationProviders.Vault
});
return configs;
@@ -480,7 +499,8 @@ export const externalMigrationServiceFactory = ({
// Get all configured namespaces for this org
const vaultConfigs = await vaultExternalMigrationConfigDAL.find({
- orgId: actor.orgId
+ orgId: actor.orgId,
+ provider: ExternalMigrationProviders.Vault
});
// Return the configured namespaces as an array of objects with id and name
@@ -621,6 +641,10 @@ export const externalMigrationServiceFactory = ({
throw new ForbiddenRequestError({ message: "Config does not belong to this organization" });
}
+ if (config.provider !== ExternalMigrationProviders.Vault) {
+ throw new NotFoundError({ message: "Vault migration config not found" });
+ }
+
const deletedConfig = await vaultExternalMigrationConfigDAL.deleteById(id);
return deletedConfig;
@@ -691,6 +715,199 @@ export const externalMigrationServiceFactory = ({
return getHCVaultLdapRoles(namespace, mountPath, connection, gatewayService, gatewayV2Service);
};
+ // ─── Doppler In-Platform Migration ──────────────────────────────────────────
+
+ const getDopplerConnectionForConfig = async (configId: string, actor: OrgServiceActor) => {
+ const { hasRole } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
+
+ if (!hasRole(OrgMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({ message: "Only admins can use Doppler migration" });
+ }
+
+ const config = await vaultExternalMigrationConfigDAL.findById(configId);
+
+ if (!config || config.orgId !== actor.orgId) {
+ throw new NotFoundError({ message: "Doppler migration config not found" });
+ }
+
+ if (!config.connectionId) {
+ throw new BadRequestError({ message: "Doppler migration config has no connection configured" });
+ }
+
+ const appConnection = await appConnectionService.connectAppConnectionById<TDopplerConnection>(
+ AppConnection.Doppler,
+ config.connectionId,
+ actor
+ );
+
+ return appConnection;
+ };
+
+ const createDopplerExternalMigration = async ({ connectionId, actor }: TCreateDopplerExternalMigrationDTO) => {
+ const { hasRole } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
+
+ if (!hasRole(OrgMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({ message: "Only admins can create Doppler migration configs" });
+ }
+
+ try {
+ const config = await vaultExternalMigrationConfigDAL.create({
+ orgId: actor.orgId,
+ connectionId,
+ provider: ExternalMigrationProviders.Doppler,
+ namespace: null
+ });
+
+ return config;
+ } catch (error) {
+ if (error instanceof DatabaseError && error.error && "code" in (error.error as object)) {
+ const dbError = error.error as { code: string };
+ if (dbError.code === DatabaseErrorCode.UniqueViolation) {
+ throw new BadRequestError({ message: "A Doppler migration config already exists for this connection" });
+ }
+ }
+ throw error;
+ }
+ };
+
+ const getDopplerExternalMigrationConfigs = async (actor: OrgServiceActor) => {
+ const { hasRole } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
+
+ if (!hasRole(OrgMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({ message: "Only admins can view Doppler migration configs" });
+ }
+
+ return vaultExternalMigrationConfigDAL.findWithConnection({
+ orgId: actor.orgId,
+ provider: ExternalMigrationProviders.Doppler
+ });
+ };
+
+ const updateDopplerExternalMigration = async ({
+ id,
+ connectionId,
+ actor
+ }: TUpdateDopplerExternalMigrationDTO) => {
+ const { hasRole } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
+
+ if (!hasRole(OrgMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({ message: "Only admins can update Doppler migration configs" });
+ }
+
+ const config = await vaultExternalMigrationConfigDAL.findById(id);
+
+ if (!config || config.orgId !== actor.orgId) {
+ throw new NotFoundError({ message: "Doppler migration config not found" });
+ }
+
+ return vaultExternalMigrationConfigDAL.updateById(id, { connectionId });
+ };
+
+ const deleteDopplerExternalMigration = async ({ id, actor }: TDeleteDopplerExternalMigrationDTO) => {
+ const { hasRole } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
+
+ if (!hasRole(OrgMembershipRole.Admin)) {
+ throw new ForbiddenRequestError({ message: "Only admins can delete Doppler migration configs" });
+ }
+
+ const config = await vaultExternalMigrationConfigDAL.findById(id);
+
+ if (!config || config.orgId !== actor.orgId) {
+ throw new NotFoundError({ message: "Doppler migration config not found" });
+ }
+
+ return vaultExternalMigrationConfigDAL.deleteById(id);
+ };
+
+ const getDopplerProjects = async ({ configId, actor }: { configId: string; actor: OrgServiceActor }) => {
+ const appConnection = await getDopplerConnectionForConfig(configId, actor);
+ return listDopplerProjects(appConnection);
+ };
+
+ const getDopplerEnvironments = async ({
+ configId,
+ projectSlug,
+ actor
+ }: {
+ configId: string;
+ projectSlug: string;
+ actor: OrgServiceActor;
+ }) => {
+ const appConnection = await getDopplerConnectionForConfig(configId, actor);
+ return listDopplerEnvironments(appConnection, projectSlug);
+ };
+
+ const importDopplerSecrets = async ({
+ configId,
+ dopplerProject,
+ dopplerEnvironment,
+ targetProjectId,
+ targetEnvironment,
+ targetSecretPath,
+ actor
+ }: TImportDopplerSecretsDTO) => {
+ const appConnection = await getDopplerConnectionForConfig(configId, actor);
+
+ const dopplerSecrets = await getDopplerSecrets(appConnection, dopplerProject, dopplerEnvironment);
+
+ try {
+ await secretService.createManySecretsRaw({
+ actorId: actor.id,
+ actor: actor.type,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ projectId: targetProjectId,
+ environment: targetEnvironment,
+ secretPath: targetSecretPath,
+ secrets: Object.entries(dopplerSecrets).map(([secretKey, secretValue]) => ({
+ secretKey,
+ secretValue
+ }))
+ });
+ } catch (error) {
+ throw new BadRequestError({
+ message: `Failed to import Doppler secrets. ${error instanceof Error ? error.message : "Unknown error"}`
+ });
+ }
+
+ return { imported: Object.keys(dopplerSecrets).length };
+ };
+
return {
importEnvKeyData,
importVaultData,
@@ -708,6 +925,13 @@ export const externalMigrationServiceFactory = ({
getVaultKubernetesAuthRoles,
getVaultKubernetesRoles,
getVaultDatabaseRoles,
- getVaultLdapRoles
+ getVaultLdapRoles,
+ createDopplerExternalMigration,
+ getDopplerExternalMigrationConfigs,
+ updateDopplerExternalMigration,
+ deleteDopplerExternalMigration,
+ getDopplerProjects,
+ getDopplerEnvironments,
+ importDopplerSecrets
};
};
diff --git a/backend/src/services/external-migration/external-migration-types.ts b/backend/src/services/external-migration/external-migration-types.ts
index 2b9069b919..58ee2ca2cd 100644
--- a/backend/src/services/external-migration/external-migration-types.ts
+++ b/backend/src/services/external-migration/external-migration-types.ts
@@ -119,12 +119,14 @@ export type TEnvKeyExportJSON = {
export enum ExternalPlatforms {
EnvKey = "EnvKey",
- Vault = "Vault"
+ Vault = "Vault",
+ Doppler = "Doppler"
}
export enum ExternalMigrationProviders {
Vault = "vault",
- EnvKey = "env-key"
+ EnvKey = "env-key",
+ Doppler = "doppler"
}
export enum VaultImportStatus {
@@ -132,6 +134,32 @@ export enum VaultImportStatus {
ApprovalRequired = "approval-required"
}
+export type TCreateDopplerExternalMigrationDTO = {
+ connectionId: string;
+ actor: OrgServiceActor;
+};
+
+export type TUpdateDopplerExternalMigrationDTO = {
+ id: string;
+ connectionId: string | null;
+ actor: OrgServiceActor;
+};
+
+export type TDeleteDopplerExternalMigrationDTO = {
+ id: string;
+ actor: OrgServiceActor;
+};
+
+export type TImportDopplerSecretsDTO = {
+ configId: string;
+ dopplerProject: string;
+ dopplerEnvironment: string;
+ targetProjectId: string;
+ targetEnvironment: string;
+ targetSecretPath: string;
+ actor: OrgServiceActor;
+};
+
export type TCreateVaultExternalMigrationDTO = {
namespace: string;
connectionId: string;