diff --git a/backend/src/server/routes/v3/external-migration-router.ts b/backend/src/server/routes/v3/external-migration-router.ts index 89621811d..4325692da 100644 --- a/backend/src/server/routes/v3/external-migration-router.ts +++ b/backend/src/server/routes/v3/external-migration-router.ts @@ -19,7 +19,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider config: { rateLimit: writeLimit }, - onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), + onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { const data = await req.file({ limits: { @@ -69,7 +69,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider mappingType: z.nativeEnum(VaultMappingType) }) }, - onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), + onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { await server.services.migration.importVaultData({ actorId: req.permission.id, diff --git a/backend/src/services/external-migration/external-migration-fns/vault.ts b/backend/src/services/external-migration/external-migration-fns/vault.ts index b512ff11a..1ebd56a80 100644 --- a/backend/src/services/external-migration/external-migration-fns/vault.ts +++ b/backend/src/services/external-migration/external-migration-fns/vault.ts @@ -254,29 +254,26 @@ export const transformToInfisicalFormatNamespaceToProjects = ( let currentFolderId: string | undefined; let currentPath = ""; - if (path.includes("/")) { - const pathParts = path.split("/").filter(Boolean); + const pathParts = path.split("/").filter(Boolean); + const folderParts = pathParts; - const folderParts = pathParts; + // create nested folder structure for the entire path + for (const folderName of folderParts) { + currentPath = currentPath ? `${currentPath}/${folderName}` : folderName; + const folderKey = `${namespace}:${mount}:${currentPath}`; - // create nested folder structure for the entire path - for (const folderName of folderParts) { - currentPath = currentPath ? `${currentPath}/${folderName}` : folderName; - const folderKey = `${namespace}:${mount}:${currentPath}`; - - if (!folderMap.has(folderKey)) { - const folderId = uuidv4(); - folderMap.set(folderKey, folderId); - folders.push({ - id: folderId, - name: folderName, - environmentId, - parentFolderId: currentFolderId || environmentId - }); - currentFolderId = folderId; - } else { - currentFolderId = folderMap.get(folderKey)!; - } + if (!folderMap.has(folderKey)) { + const folderId = uuidv4(); + folderMap.set(folderKey, folderId); + folders.push({ + id: folderId, + name: folderName, + environmentId, + parentFolderId: currentFolderId || environmentId + }); + currentFolderId = folderId; + } else { + currentFolderId = folderMap.get(folderKey)!; } }