mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 19:28:16 +00:00
Avoid throwing forbidden on non accessible resources and return an empty response for those
This commit is contained in:
@@ -487,7 +487,22 @@ export const secretImportServiceFactory = ({
|
|||||||
actorOrgId,
|
actorOrgId,
|
||||||
actionProjectType: ActionProjectType.SecretManager
|
actionProjectType: ActionProjectType.SecretManager
|
||||||
});
|
});
|
||||||
|
const filteredEnvironments = [];
|
||||||
for (const environment of environments) {
|
for (const environment of environments) {
|
||||||
|
if (
|
||||||
|
permission.can(
|
||||||
|
ProjectPermissionActions.Read,
|
||||||
|
subject(ProjectPermissionSub.SecretImports, { environment, secretPath })
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
filteredEnvironments.push(environment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filteredEnvironments.length === 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const environment of filteredEnvironments) {
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.SecretImports, { environment, secretPath })
|
subject(ProjectPermissionSub.SecretImports, { environment, secretPath })
|
||||||
@@ -745,14 +760,22 @@ export const secretImportServiceFactory = ({
|
|||||||
actorOrgId,
|
actorOrgId,
|
||||||
actionProjectType: ActionProjectType.SecretManager
|
actionProjectType: ActionProjectType.SecretManager
|
||||||
});
|
});
|
||||||
|
const filteredEnvironments = [];
|
||||||
for (const environment of environments) {
|
for (const environment of environments) {
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
if (
|
||||||
ProjectPermissionActions.Read,
|
permission.can(
|
||||||
subject(ProjectPermissionSub.SecretImports, { environment, secretPath })
|
ProjectPermissionActions.Read,
|
||||||
);
|
subject(ProjectPermissionSub.SecretImports, { environment, secretPath })
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
filteredEnvironments.push(environment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filteredEnvironments.length === 0) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const folders = await folderDAL.findBySecretPathMultiEnv(projectId, environments, secretPath);
|
const folders = await folderDAL.findBySecretPathMultiEnv(projectId, filteredEnvironments, secretPath);
|
||||||
if (!folders?.length)
|
if (!folders?.length)
|
||||||
throw new NotFoundError({
|
throw new NotFoundError({
|
||||||
message: `Folder with path '${secretPath}' not found on environments with slugs '${environments.join(", ")}'`
|
message: `Folder with path '${secretPath}' not found on environments with slugs '${environments.join(", ")}'`
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ export const useGetImportedSecretsAllEnvs = ({
|
|||||||
select: useCallback(
|
select: useCallback(
|
||||||
(data: Awaited<ReturnType<typeof fetchImportedSecrets>>) =>
|
(data: Awaited<ReturnType<typeof fetchImportedSecrets>>) =>
|
||||||
data.map((el) => ({
|
data.map((el) => ({
|
||||||
currentEnv: env,
|
|
||||||
environment: el.environment,
|
environment: el.environment,
|
||||||
secretPath: el.secretPath,
|
secretPath: el.secretPath,
|
||||||
environmentInfo: el.environmentInfo,
|
environmentInfo: el.environmentInfo,
|
||||||
|
|||||||
Reference in New Issue
Block a user