mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-20 19:02:03 +00:00
feat(infisical-pg): resolved import secret breaking cli backward compatiability
This commit is contained in:
@@ -250,7 +250,8 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
||||
secrets: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
environment: z.string(),
|
||||
environmentInfo: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
SecretsSchema,
|
||||
SecretTagsSchema,
|
||||
SecretType,
|
||||
ServiceTokenScopes,
|
||||
ServiceTokenScopes
|
||||
} from "@app/db/schemas";
|
||||
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
||||
import { CommitType } from "@app/ee/services/secret-approval-request/secret-approval-request-types";
|
||||
@@ -36,11 +36,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
imports: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
}),
|
||||
environment: z.string(),
|
||||
folderId: z.string().optional(),
|
||||
secrets: secretRawSchema.array()
|
||||
})
|
||||
@@ -57,23 +53,24 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
]),
|
||||
handler: async (req) => {
|
||||
// just for delivery hero usecase
|
||||
let {secretPath,environment,workspaceId} = req.query;
|
||||
if(req.auth.actor === ActorType.SERVICE){
|
||||
let { secretPath, environment, workspaceId } = req.query;
|
||||
if (req.auth.actor === ActorType.SERVICE) {
|
||||
const scope = ServiceTokenScopes.parse(req.auth.serviceToken.scopes);
|
||||
const isSingleScope = scope.length === 1;
|
||||
if(isSingleScope && !picomatch.scan(scope[0].secretPath).isGlob){
|
||||
if (isSingleScope && !picomatch.scan(scope[0].secretPath).isGlob) {
|
||||
secretPath = scope[0].secretPath;
|
||||
environment = scope[0].environment;
|
||||
workspaceId = req.auth.serviceToken.projectId;
|
||||
}
|
||||
}
|
||||
|
||||
if(!workspaceId || !environment) throw new BadRequestError({message:"Missing workspace id or environment"})
|
||||
if (!workspaceId || !environment)
|
||||
throw new BadRequestError({ message: "Missing workspace id or environment" });
|
||||
|
||||
const { secrets, imports } = await server.services.secret.getSecretsRaw({
|
||||
actorId: req.permission.id,
|
||||
actor: req.permission.type,
|
||||
environment,
|
||||
environment,
|
||||
projectId: workspaceId as string,
|
||||
path: secretPath,
|
||||
includeImports: req.query.include_imports
|
||||
@@ -360,11 +357,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
imports: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
}),
|
||||
environment: z.string(),
|
||||
folderId: z.string().optional(),
|
||||
secrets: SecretsSchema.omit({ secretBlindIndex: true }).array()
|
||||
})
|
||||
|
||||
@@ -33,7 +33,8 @@ export const fnSecretsFromImports = async ({
|
||||
const importedSecsGroupByFolderId = groupBy(importedSecrets, (i) => i.folderId);
|
||||
return allowedImports.map(({ importPath, importEnv }, i) => ({
|
||||
secretPath: importPath,
|
||||
environment: importEnv,
|
||||
environment: importEnv.slug,
|
||||
environmentInfo: importEnv,
|
||||
folderId: importedFolders?.[i]?.id,
|
||||
secrets: importedFolders?.[i]?.id
|
||||
? importedSecsGroupByFolderId[importedFolders?.[i]?.id as string]
|
||||
|
||||
@@ -585,7 +585,7 @@ export const secretServiceFactory = ({
|
||||
return {
|
||||
...importedSecrets[i].secrets[j],
|
||||
workspace: projectId,
|
||||
environment: importedSecrets[i].environment.slug
|
||||
environment: importedSecrets[i].environment
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -825,10 +825,7 @@ export const secretServiceFactory = ({
|
||||
imports: (imports || [])?.map(({ secrets: importedSecrets, ...el }) => ({
|
||||
...el,
|
||||
secrets: importedSecrets.map((sec) =>
|
||||
decryptSecretRaw(
|
||||
{ ...sec, environment: el.environment.slug, workspace: projectId },
|
||||
botKey
|
||||
)
|
||||
decryptSecretRaw({ ...sec, environment: el.environment, workspace: projectId }, botKey)
|
||||
)
|
||||
}))
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user