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
add support to app connection on imports
adilson1c8408d03f60
diff --git a/backend/src/server/routes/v3/external-migration-router.ts b/backend/src/server/routes/v3/external-migration-router.tsindex 88e95644e7..599493aa8c 100644--- a/backend/src/server/routes/v3/external-migration-router.ts+++ b/backend/src/server/routes/v3/external-migration-router.ts@@ -1,15 +1,11 @@import fastifyMultipart from "@fastify/multipart";import { z } from "zod";-import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { BadRequestError } from "@app/lib/errors";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";-import {- ExternalMigrationConfigSchema,- ExternalMigrationProviders-} from "@app/services/external-migration/external-migration-schemas";+import { ExternalMigrationProviders } from "@app/services/external-migration/external-migration-schemas";import {ExternalMigrationImportStatus,VaultMappingType@@ -124,199 +120,6 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider}});- server.route({- method: "GET",- url: "/:provider/configs",- config: {- rateLimit: readLimit- },- schema: {- operationId: "getExternalMigrationConfigsV3",- params: z.object({- provider: z.nativeEnum(ExternalMigrationProviders)- }),- response: {- 200: z.object({- configs: z- .object({- id: z.string(),- orgId: z.string(),- provider: z.string(),- connectionId: z.string().nullish(),- createdAt: z.date(),- updatedAt: z.date()- })- .array()- })- }- },- onRequest: verifyAuth([AuthMode.JWT]),- handler: async (req) => {- const configs = await server.services.migration.getExternalMigrationConfigs({- actor: req.permission,- provider: req.params.provider- });-- return { configs };- }- });-- server.route({- method: "POST",- url: "/:provider/configs",- config: {- rateLimit: writeLimit- },- schema: {- operationId: "createExternalMigrationV3",- params: z.object({- provider: z.nativeEnum(ExternalMigrationProviders)- }),- body: z.object({- connectionId: z.string(),- input: ExternalMigrationConfigSchema- }),- response: {- 200: z.object({- config: z.object({- id: z.string(),- orgId: z.string(),- provider: z.string(),- connectionId: z.string().nullish(),- createdAt: z.date(),- updatedAt: z.date()- })- })- }- },- onRequest: verifyAuth([AuthMode.JWT]),- handler: async (req) => {- const config = await server.services.migration.createExternalMigration({- config: req.body.input,- connectionId: req.body.connectionId,- actor: req.permission- });-- await server.services.auditLog.createAuditLog({- orgId: req.permission.orgId,- ...req.auditLogInfo,- event: {- type: EventType.EXTERNAL_MIGRATION_CREATE,- metadata: {- configId: config.id,- provider: req.params.provider,- connectionId: req.body.connectionId- }- }- });-- return { config };- }- });-- server.route({- method: "PUT",- url: "/:provider/configs/:id",- config: {- rateLimit: writeLimit- },- schema: {- operationId: "updateExternalMigrationV3",- params: z.object({- provider: z.nativeEnum(ExternalMigrationProviders),- id: z.string()- }),- body: z.object({- connectionId: z.string().nullable(),- input: ExternalMigrationConfigSchema- }),- response: {- 200: z.object({- config: z.object({- id: z.string(),- orgId: z.string(),- provider: z.string(),- connectionId: z.string().nullish(),- createdAt: z.date(),- updatedAt: z.date()- })- })- }- },- onRequest: verifyAuth([AuthMode.JWT]),- handler: async (req) => {- const config = await server.services.migration.updateExternalMigration({- id: req.params.id,- config: req.body.input,- connectionId: req.body.connectionId,- actor: req.permission- });-- await server.services.auditLog.createAuditLog({- orgId: req.permission.orgId,- ...req.auditLogInfo,- event: {- type: EventType.EXTERNAL_MIGRATION_UPDATE,- metadata: {- configId: req.params.id,- provider: req.params.provider,- connectionId: req.body.connectionId- }- }- });-- return { config };- }- });-- server.route({- method: "DELETE",- url: "/:provider/configs/:id",- config: {- rateLimit: writeLimit- },- schema: {- operationId: "deleteExternalMigrationV3",- params: z.object({- provider: z.nativeEnum(ExternalMigrationProviders),- id: z.string()- }),- response: {- 200: z.object({- config: z.object({- id: z.string(),- orgId: z.string(),- provider: z.string(),- connectionId: z.string().nullish(),- createdAt: z.date(),- updatedAt: z.date()- })- })- }- },- onRequest: verifyAuth([AuthMode.JWT]),- handler: async (req) => {- const config = await server.services.migration.deleteExternalMigration({- id: req.params.id,- actor: req.permission- });-- await server.services.auditLog.createAuditLog({- orgId: req.permission.orgId,- ...req.auditLogInfo,- event: {- type: EventType.EXTERNAL_MIGRATION_DELETE,- metadata: {- configId: req.params.id,- provider: req.params.provider- }- }- });-- return { config };- }- });-server.route({method: "GET",url: "/vault/namespaces",@@ -354,7 +157,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderschema: {operationId: "getVaultPoliciesV3",querystring: z.object({- namespace: z.string()+ namespace: z.string(),+ connectionId: z.string().uuid().optional()}),response: {200: z.object({@@ -366,7 +170,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderhandler: async (req) => {const policies = await server.services.migration.getVaultPolicies({actor: req.permission,- namespace: req.query.namespace+ namespace: req.query.namespace,+ connectionId: req.query.connectionId});return { policies };@@ -413,7 +218,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvideroperationId: "getVaultAuthMountsV3",querystring: z.object({namespace: z.string(),- authType: z.string().optional()+ authType: z.string().optional(),+ connectionId: z.string().uuid().optional()}),response: {200: z.object({@@ -426,7 +232,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderconst mounts = await server.services.migration.getVaultAuthMounts({actor: req.permission,namespace: req.query.namespace,- authType: req.query.authType+ authType: req.query.authType,+ connectionId: req.query.connectionId});return { mounts };@@ -477,7 +284,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvideroperationId: "getVaultKubernetesRolesV3",querystring: z.object({namespace: z.string(),- mountPath: z.string()+ mountPath: z.string(),+ connectionId: z.string().uuid().optional()}),response: {200: z.object({@@ -511,7 +319,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderconst roles = await server.services.migration.getVaultKubernetesRoles({actor: req.permission,namespace: req.query.namespace,- mountPath: req.query.mountPath+ mountPath: req.query.mountPath,+ connectionId: req.query.connectionId});return { roles };@@ -528,7 +337,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvideroperationId: "getVaultDatabaseRolesV3",querystring: z.object({namespace: z.string(),- mountPath: z.string()+ mountPath: z.string(),+ connectionId: z.string().uuid().optional()}),response: {200: z.object({@@ -561,7 +371,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderconst roles = await server.services.migration.getVaultDatabaseRoles({actor: req.permission,namespace: req.query.namespace,- mountPath: req.query.mountPath+ mountPath: req.query.mountPath,+ connectionId: req.query.connectionId});return { roles };@@ -610,7 +421,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvideroperationId: "getVaultKubernetesAuthRolesV3",querystring: z.object({namespace: z.string(),- mountPath: z.string()+ mountPath: z.string(),+ connectionId: z.string().uuid().optional()}),response: {@@ -649,7 +461,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderconst roles = await server.services.migration.getVaultKubernetesAuthRoles({actor: req.permission,namespace: req.query.namespace,- mountPath: req.query.mountPath+ mountPath: req.query.mountPath,+ connectionId: req.query.connectionId});return { roles };@@ -666,7 +479,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvideroperationId: "getVaultLdapRolesV3",querystring: z.object({namespace: z.string(),- mountPath: z.string()+ mountPath: z.string(),+ connectionId: z.string().uuid().optional()}),response: {200: z.object({@@ -695,7 +509,8 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProviderconst roles = await server.services.migration.getVaultLdapRoles({actor: req.permission,namespace: req.query.namespace,- mountPath: req.query.mountPath+ mountPath: req.query.mountPath,+ connectionId: req.query.connectionId});return { roles };diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 056cb0849b..b1493b6b96 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -22,6 +22,7 @@ import {transferSqlConnectionCredentialsToPlatform,validateSqlConnectionCredentials} from "@app/services/app-connection/shared/sql";+import { EXTERNAL_MIGRATION_APP_CONNECTIONS } from "@app/services/external-migration/external-migration-map";import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";import { KmsDataKey } from "@app/services/kms/kms-types";import { SECRET_SYNC_CONNECTION_MAP } from "@app/services/secret-sync/secret-sync-maps";@@ -334,7 +335,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {case ProjectType.SecretManager:return (Boolean(SECRET_SYNC_APP_CONNECTION_MAP[option.app]) ||- Boolean(SECRET_ROTATION_APP_CONNECTION_MAP[option.app])+ Boolean(SECRET_ROTATION_APP_CONNECTION_MAP[option.app]) ||+ EXTERNAL_MIGRATION_APP_CONNECTIONS.includes(option.app));case ProjectType.SecretScanning:return Boolean(SECRET_SCANNING_APP_CONNECTION_MAP[option.app]);@@ -393,7 +395,7 @@ export const decryptAppConnectionCredentials = async ({encryptedCredentials: Buffer;kmsService: TAppConnectionServiceFactoryDep["kmsService"];projectId: string | null | undefined;-}) => {+}): Promise<TAppConnection["credentials"]> => {const { decryptor } = await kmsService.createCipherPairWithDataKey(projectId? { type: KmsDataKey.SecretManager, projectId }@@ -407,7 +409,7 @@ export const decryptAppConnectionCredentials = async ({cipherTextBlob: encryptedCredentials});- return JSON.parse(decryptedPlainTextBlob.toString()) as TAppConnection["credentials"];+ return JSON.parse(decryptedPlainTextBlob.toString()) as unknown as TAppConnection["credentials"];};export const validateAppConnectionCredentials = async (diff --git a/backend/src/services/external-migration/external-migration-map.ts b/backend/src/services/external-migration/external-migration-map.tsnew file mode 100644index 0000000000..7e86abe12a--- /dev/null+++ b/backend/src/services/external-migration/external-migration-map.ts@@ -0,0 +1,6 @@+import { AppConnection } from "../app-connection/app-connection-enums";++export const EXTERNAL_MIGRATION_APP_CONNECTIONS: readonly AppConnection[] = [+ AppConnection.HCVault,+ AppConnection.Doppler+] as const;diff --git a/backend/src/services/external-migration/external-migration-schemas.ts b/backend/src/services/external-migration/external-migration-schemas.tsindex ae16ba3b36..3e567c635c 100644--- a/backend/src/services/external-migration/external-migration-schemas.ts+++ b/backend/src/services/external-migration/external-migration-schemas.ts@@ -9,18 +9,3 @@ export enum ExternalMigrationProviders {export const ExternalMigrationConfigVaultConfigSchema = z.object({namespace: z.string()});--export const ExternalMigrationConfigDopplerConfigSchema = z.object({});--export const ExternalMigrationConfigSchema = z.discriminatedUnion("provider", [- z.object({- provider: z.literal(ExternalMigrationProviders.Vault),- config: ExternalMigrationConfigVaultConfigSchema- }),- z.object({- provider: z.literal(ExternalMigrationProviders.Doppler),- config: ExternalMigrationConfigDopplerConfigSchema- })-]);--export type TExternalMigrationConfig = z.infer<typeof ExternalMigrationConfigSchema>;diff --git a/backend/src/services/external-migration/external-migration-service.ts b/backend/src/services/external-migration/external-migration-service.tsindex 5a929ebaef..a49ffc2dfe 100644--- a/backend/src/services/external-migration/external-migration-service.ts+++ b/backend/src/services/external-migration/external-migration-service.ts@@ -26,7 +26,6 @@ import {getHCVaultKubernetesAuthRoles,getHCVaultKubernetesRoles,getHCVaultLdapRoles,- getHCVaultPolicyNames,getHCVaultSecretsForPaths,HCVaultAuthType,JsonValue,@@ -58,13 +57,10 @@ import { ExternalMigrationConfigVaultConfigSchema, ExternalMigrationProviders }import {ExternalMigrationImportStatus,ExternalPlatforms,- TCreateExternalMigrationDTO,- TDeleteExternalMigrationDTO,THasCustomVaultMigrationDTO,TImportDopplerSecretsDTO,TImportEnvKeyDataDTO,- TImportVaultDataDTO,- TUpdateExternalMigrationDTO+ TImportVaultDataDTO} from "./external-migration-types";type TExternalMigrationServiceFactoryDep = {@@ -73,10 +69,7 @@ type TExternalMigrationServiceFactoryDep = {auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;externalMigrationQueue: TExternalMigrationQueueFactory;appConnectionService: Pick<TAppConnectionServiceFactory, "connectAppConnectionById">;- externalMigrationConfigDAL: Pick<- TExternalMigrationConfigDALFactory,- "create" | "findOne" | "transaction" | "find" | "updateById" | "deleteById" | "findById" | "findWithConnection"- >;+ externalMigrationConfigDAL: Pick<TExternalMigrationConfigDALFactory, "find" | "findWithConnection" | "findById">;userDAL: Pick<TUserDALFactory, "findById">;gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;@@ -355,208 +348,6 @@ export const externalMigrationServiceFactory = ({return actorOrgId in vaultMigrationTransformMappings;};- const validateVaultExternalMigrationConnection = async ({- connection,- namespace- }: {- connection: THCVaultConnection;- namespace: string;- }) => {- if (connection.projectId != null) {- throw new BadRequestError({- message:- "Vault external migration requires an organization-level HashiCorp Vault app connection. Project-scoped app connections cannot be used."- });- }-- // Allow root namespace access when no namespace is configured on the connection- const isRootAccess = namespace === "root" || namespace === "/";- const hasNoNamespace = connection.credentials.namespace === undefined;-- if (hasNoNamespace && isRootAccess) {- // Skip validation for root access with no configured namespace- } else if (connection.credentials.namespace !== namespace) {- throw new BadRequestError({ message: "Namespace value does not match the namespace of the connection" });- }-- const gatewayDetails = await getGatewayDetails(connection);-- try {- await getHCVaultPolicyNames(namespace, connection, gatewayService, gatewayV2Service, gatewayDetails);- await getHCVaultAuthMounts(- namespace,- HCVaultAuthType.Kubernetes,- connection,- gatewayService,- gatewayV2Service,- gatewayDetails- );-- await listHCVaultMounts(connection, gatewayService, gatewayV2Service);- } catch (error) {- throw new BadRequestError({- message: `Failed to establish namespace configuration. ${error instanceof Error ? error.message : "Unknown error"}`- });- }- };-- const createExternalMigration = async ({- config: migrationConfig,- connectionId,- actor- }: TCreateExternalMigrationDTO) => {- const { hasRole } = await permissionService.getOrgPermission({- actorId: actor.id,- actor: actor.type,- orgId: actor.orgId,- actorOrgId: actor.orgId,- actorAuthMethod: actor.authMethod,- scope: OrganizationActionScope.Any- });-- if (!hasRole(OrgMembershipRole.Admin)) {- throw new ForbiddenRequestError({ message: "Only admins can create external migration" });- }-- const existingConfigs = await externalMigrationConfigDAL.find({- orgId: actor.orgId,- provider: migrationConfig.provider- });-- const { decryptor, encryptor } = await kmsService.createCipherPairWithDataKey({- type: KmsDataKey.Organization,- orgId: actor.orgId- });-- if (migrationConfig.provider === ExternalMigrationProviders.Vault) {- if (existingConfigs?.length) {- const parsedConfigs = existingConfigs.map((cfg) => {- const decryptedConfig = decryptor({ cipherTextBlob: cfg.encryptedConfig });- return ExternalMigrationConfigVaultConfigSchema.parse(JSON.parse(decryptedConfig.toString()));- });-- if (parsedConfigs.some((cfg) => cfg.namespace === migrationConfig.config.namespace)) {- throw new BadRequestError({ message: "A Vault external migration already exists for this namespace" });- }- }-- const connection = await appConnectionService.connectAppConnectionById<THCVaultConnection>(- AppConnection.HCVault,- connectionId,- actor- );- await validateVaultExternalMigrationConnection({- connection,- namespace: migrationConfig.config.namespace- });- } else if (migrationConfig.provider === ExternalMigrationProviders.Doppler) {- await appConnectionService.connectAppConnectionById(AppConnection.Doppler, connectionId, actor);-- if (existingConfigs?.length) {- if (existingConfigs.some((cfg) => cfg.connectionId === connectionId)) {- throw new BadRequestError({- message: "A Doppler external migration already exists with the same app connection"- });- }- }- }-- const externalMigrationConfig = await externalMigrationConfigDAL.create({- orgId: actor.orgId,- provider: migrationConfig.provider,- encryptedConfig: encryptor({ plainText: Buffer.from(JSON.stringify(migrationConfig.config)) }).cipherTextBlob,- connectionId- });-- return externalMigrationConfig;- };-- const updateExternalMigration = async ({- id,- config: migrationConfig,- connectionId,- actor- }: TUpdateExternalMigrationDTO) => {- const { hasRole } = await permissionService.getOrgPermission({- actorId: actor.id,- actor: actor.type,- orgId: actor.orgId,- actorOrgId: actor.orgId,- actorAuthMethod: actor.authMethod,- scope: OrganizationActionScope.Any- });-- if (!hasRole(OrgMembershipRole.Admin)) {- throw new ForbiddenRequestError({ message: "Only admins can update external migration" });- }-- const existing = await externalMigrationConfigDAL.findById(id);- if (!existing || existing.orgId !== actor.orgId) {- throw new NotFoundError({ message: "External migration config not found" });- }-- if (existing.provider !== migrationConfig.provider) {- throw new BadRequestError({ message: "Cannot change provider of an existing migration config" });- }-- const { encryptor } = await kmsService.createCipherPairWithDataKey({- type: KmsDataKey.Organization,- orgId: actor.orgId- });-- if (migrationConfig.provider === ExternalMigrationProviders.Vault) {- if (connectionId) {- const connection = await appConnectionService.connectAppConnectionById<THCVaultConnection>(- AppConnection.HCVault,- connectionId,- actor- );-- await validateVaultExternalMigrationConnection({- connection,- namespace: migrationConfig.config.namespace- });- }- } else if (migrationConfig.provider === ExternalMigrationProviders.Doppler) {- if (connectionId) {- await appConnectionService.connectAppConnectionById(AppConnection.Doppler, connectionId, actor);- }- }-- const updatedConfig = await externalMigrationConfigDAL.updateById(id, {- encryptedConfig: encryptor({ plainText: Buffer.from(JSON.stringify(migrationConfig.config)) }).cipherTextBlob,- connectionId- });-- return updatedConfig;- };-- const getExternalMigrationConfigs = async ({- actor,- provider- }: {- actor: OrgServiceActor;- provider: ExternalMigrationProviders;- }) => {- const { hasRole } = await permissionService.getOrgPermission({- actorId: actor.id,- actor: actor.type,- orgId: actor.orgId,- actorOrgId: actor.orgId,- actorAuthMethod: actor.authMethod,- scope: OrganizationActionScope.Any- });-- if (!hasRole(OrgMembershipRole.Admin)) {- throw new ForbiddenRequestError({ message: "Only admins can view external migration configs" });- }-- return externalMigrationConfigDAL.findWithConnection({- orgId: actor.orgId,- provider- });- };-const getVaultNamespaces = async ({ actor, connectionId }: { actor: OrgServiceActor; connectionId?: string }) => {if (connectionId) {const connection = await getVaultConnectionById(connectionId, actor);@@ -603,8 +394,20 @@ export const externalMigrationServiceFactory = ({return namespaces;};- const getVaultPolicies = async ({ actor, namespace }: { actor: OrgServiceActor; namespace: string }) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "view vault policies");+ const getVaultPolicies = async ({+ actor,+ namespace,+ connectionId+ }: {+ actor: OrgServiceActor;+ namespace: string;+ connectionId?: string;+ }) => {+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "view vault policies"+ });const gatewayDetails = await getGatewayDetails(connection);@@ -767,98 +570,105 @@ export const externalMigrationServiceFactory = ({}};- const deleteExternalMigration = async ({ id, actor }: TDeleteExternalMigrationDTO) => {- const { hasRole } = await permissionService.getOrgPermission({- actorId: actor.id,- actor: actor.type,- orgId: actor.orgId,- actorOrgId: actor.orgId,- actorAuthMethod: actor.authMethod,- scope: OrganizationActionScope.Any- });-- if (!hasRole(OrgMembershipRole.Admin)) {- throw new ForbiddenRequestError({ message: "Only admins can delete external migration configs" });- }-- const config = await externalMigrationConfigDAL.findById(id);-- if (!config || config.orgId !== actor.orgId) {- throw new NotFoundError({ message: "External migration config not found" });- }-- return externalMigrationConfigDAL.deleteById(id);- };-const getVaultAuthMounts = async ({actor,namespace,- authType+ authType,+ connectionId}: {actor: OrgServiceActor;namespace: string;authType?: string;+ connectionId?: string;}) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "view vault auth mounts");+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "view vault auth mounts"+ });return getHCVaultAuthMounts(namespace, authType as HCVaultAuthType, connection, gatewayService, gatewayV2Service);};const getVaultKubernetesAuthRoles = async ({actor,namespace,- mountPath+ mountPath,+ connectionId}: {actor: OrgServiceActor;namespace: string;mountPath: string;+ connectionId?: string;}) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "view vault Kubernetes auth roles");+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "view vault Kubernetes auth roles"+ });return getHCVaultKubernetesAuthRoles(namespace, mountPath, connection, gatewayService, gatewayV2Service);};const getVaultKubernetesRoles = async ({actor,namespace,- mountPath+ mountPath,+ connectionId}: {actor: OrgServiceActor;namespace: string;mountPath: string;+ connectionId?: string;}) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "get Kubernetes roles");+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "get Kubernetes roles"+ });return getHCVaultKubernetesRoles(namespace, mountPath, connection, gatewayService, gatewayV2Service);};const getVaultDatabaseRoles = async ({actor,namespace,- mountPath+ mountPath,+ connectionId}: {actor: OrgServiceActor;namespace: string;mountPath: string;+ connectionId?: string;}) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "get database roles");+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "get database roles"+ });return getHCVaultDatabaseRoles(namespace, mountPath, connection, gatewayService, gatewayV2Service);};const getVaultLdapRoles = async ({actor,namespace,- mountPath+ mountPath,+ connectionId}: {actor: OrgServiceActor;namespace: string;mountPath: string;+ connectionId?: string;}) => {- const connection = await getVaultConnectionForNamespace(actor, namespace, "get LDAP roles");+ const connection = await resolveVaultConnection(actor, {+ namespace,+ connectionId,+ action: "get LDAP roles"+ });return getHCVaultLdapRoles(namespace, mountPath, connection, gatewayService, gatewayV2Service);};// ─── Doppler In-Platform Migration ──────────────────────────────────────────// CASL is enforced inside connectAppConnectionById for project- or org-scoped connections.- const getDopplerConnectionById = async (connectionId: string, actor: OrgServiceActor) =>+ const getDopplerConnection = (connectionId: string, actor: OrgServiceActor) =>appConnectionService.connectAppConnectionById<TDopplerConnection>(AppConnection.Doppler, connectionId, actor);const getDopplerConnectionForConfig = async (configId: string, actor: OrgServiceActor) => {@@ -870,35 +680,29 @@ export const externalMigrationServiceFactory = ({actorAuthMethod: actor.authMethod,actorOrgId: actor.orgId});-if (!hasRole(OrgMembershipRole.Admin)) {throw new ForbiddenRequestError({ message: "Only admins can use Doppler migration" });}const config = await externalMigrationConfigDAL.findById(configId);-if (!config || config.orgId !== actor.orgId || config.provider !== ExternalMigrationProviders.Doppler) {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>(+ return appConnectionService.connectAppConnectionById<TDopplerConnection>(AppConnection.Doppler,config.connectionId,actor);-- return appConnection;};- const resolveDopplerConnection = async (+ const resolveDopplerConnection = (actor: OrgServiceActor,{ configId, connectionId }: { configId?: string; connectionId?: string }) => {- if (connectionId) return getDopplerConnectionById(connectionId, actor);+ if (connectionId) return getDopplerConnection(connectionId, actor);if (configId) return getDopplerConnectionForConfig(configId, actor);throw new BadRequestError({ message: "Either connectionId or configId must be provided" });};@@ -1012,11 +816,6 @@ export const externalMigrationServiceFactory = ({importVaultData,hasCustomVaultMigration,- createExternalMigration,- updateExternalMigration,- deleteExternalMigration,- getExternalMigrationConfigs,-getVaultNamespaces,getVaultPolicies,getVaultMounts,diff --git a/backend/src/services/external-migration/external-migration-types.ts b/backend/src/services/external-migration/external-migration-types.tsindex 77b883a247..bccd58116d 100644--- a/backend/src/services/external-migration/external-migration-types.ts+++ b/backend/src/services/external-migration/external-migration-types.ts@@ -2,7 +2,7 @@ import { AuditLogInfo } from "@app/ee/services/audit-log/audit-log-types";import { OrgServiceActor, TOrgPermission } from "@app/lib/types";import { ActorAuthMethod, ActorType } from "../auth/auth-type";-import { ExternalMigrationProviders, TExternalMigrationConfig } from "./external-migration-schemas";+import { ExternalMigrationProviders } from "./external-migration-schemas";export enum KvVersion {V1 = "1",@@ -130,22 +130,6 @@ export enum ExternalMigrationImportStatus {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;connectionId?: string;@@ -157,34 +141,3 @@ export type TImportDopplerSecretsDTO = {actor: OrgServiceActor;auditLogInfo: AuditLogInfo;};--export type TCreateVaultExternalMigrationDTO = {- namespace: string;- connectionId: string;- actor: OrgServiceActor;-};--export type TUpdateVaultExternalMigrationDTO = {- id: string;- namespace: string;- connectionId: string | null;- actor: OrgServiceActor;-};--export type TCreateExternalMigrationDTO = {- config: TExternalMigrationConfig;- connectionId: string;- actor: OrgServiceActor;-};--export type TUpdateExternalMigrationDTO = {- id: string;- config: TExternalMigrationConfig;- connectionId: string | null;- actor: OrgServiceActor;-};--export type TDeleteExternalMigrationDTO = {- id: string;- actor: OrgServiceActor;-};