Skip to content

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

show revoked grants in UI

Matheus Nogueira8cd4861d6474
diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.ts
index 2efbb2c73b..2340ba7ff6 100644
--- a/backend/src/server/routes/v1/dashboard-router.ts
+++ b/backend/src/server/routes/v1/dashboard-router.ts
@@ -159,7 +159,8 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
projectId: z.string().optional()
}),
sourceProjectName: z.string().optional(),
- environment: z.string()
+ environment: z.string(),
+ isAccessRevoked: z.boolean()
})
.array()
.optional(),
@@ -723,7 +724,8 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
id: z.string(),
projectId: z.string().optional()
}),
- sourceProjectName: z.string().optional()
+ sourceProjectName: z.string().optional(),
+ isAccessRevoked: z.boolean()
})
.array()
.optional(),
diff --git a/backend/src/services/secret-import/secret-import-service.ts b/backend/src/services/secret-import/secret-import-service.ts
index 0802344f9f..e45f23f3f4 100644
--- a/backend/src/services/secret-import/secret-import-service.ts
+++ b/backend/src/services/secret-import/secret-import-service.ts
@@ -76,17 +76,17 @@ export const secretImportServiceFactory = ({
secretV2BridgeDAL,
kmsService
}: TSecretImportServiceFactoryDep) => {
- // Filters out cross-project imports that no longer have a valid grant.
+ // Annotates cross-project imports with isAccessRevoked based on grant status.
// The org-level toggle is enforced at grant creation time in project-grant-service;
// here the grant is the single source of truth for per-import access.
- const $filterCrossProjectImports = async <
+ const $annotateCrossProjectImports = async <
T extends { id: string; importEnv: { id: string; projectId?: string | null }; importPath: string }
>(
imports: T[],
projectId: string
- ): Promise<T[]> => {
+ ): Promise<(T & { isAccessRevoked: boolean })[]> => {
const crossProject = imports.filter((imp) => imp.importEnv.projectId !== projectId);
- if (!crossProject.length) return imports;
+ if (!crossProject.length) return imports.map((imp) => ({ ...imp, isAccessRevoked: false }));
const sourceFolders = await folderDAL.findByManySecretPath(
crossProject.map((imp) => ({ envId: imp.importEnv.id, secretPath: imp.importPath }))
@@ -101,16 +101,19 @@ export const secretImportServiceFactory = ({
grants.forEach((g) => grantedFolderIds.add(g.sourceFolderId));
}
- const validCrossProjectIds = new Set(
+ const revokedIds = new Set(
crossProject
.filter((_, idx) => {
const folder = sourceFolders[idx];
- return folder && grantedFolderIds.has(folder.id);
+ return !folder || !grantedFolderIds.has(folder.id);
})
.map((imp) => imp.id)
);
- return imports.filter((imp) => imp.importEnv.projectId === projectId || validCrossProjectIds.has(imp.id));
+ return imports.map((imp) => ({
+ ...imp,
+ isAccessRevoked: revokedIds.has(imp.id)
+ }));
};
const createImport = async ({
@@ -700,7 +703,7 @@ export const secretImportServiceFactory = ({
});
const secImports = await secretImportDAL.find({ folderId: folder.id, search, limit, offset });
- return $filterCrossProjectImports(secImports, projectId);
+ return $annotateCrossProjectImports(secImports, projectId);
};
const getImportById = async ({
@@ -795,10 +798,12 @@ export const secretImportServiceFactory = ({
if (!folder) return [];
// this will already order by position
// so anything based on this order will also be in right position
- const secretImports = await $filterCrossProjectImports(
- await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
- projectId
- );
+ const secretImports = (
+ await $annotateCrossProjectImports(
+ await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
+ projectId
+ )
+ ).filter((imp) => !imp.isAccessRevoked);
const allowedImports = secretImports.filter((el) =>
hasSecretReadValueOrDescribePermission(permission, ProjectPermissionSecretActions.ReadValue, {
environment: el.importEnv.slug,
@@ -834,10 +839,12 @@ export const secretImportServiceFactory = ({
if (!folder) return [];
// this will already order by position
// so anything based on this order will also be in right position
- const secretImports = await $filterCrossProjectImports(
- await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
- projectId
- );
+ const secretImports = (
+ await $annotateCrossProjectImports(
+ await secretImportDAL.find({ folderId: folder.id, isReplication: false }),
+ projectId
+ )
+ ).filter((imp) => !imp.isAccessRevoked);
const { botKey, shouldUseSecretV2Bridge } = await projectBotService.getBotKey(projectId);
if (shouldUseSecretV2Bridge) {
@@ -946,7 +953,8 @@ export const secretImportServiceFactory = ({
const secImportsArrays = await Promise.all(
folders.map(async (folder) => {
const imports = await secretImportDAL.find({ folderId: folder.id, search, limit, offset });
- return imports.map((importItem) => ({
+ const annotated = await $annotateCrossProjectImports(imports, projectId);
+ return annotated.map((importItem) => ({
...importItem,
environment: folder.environment.slug
}));
diff --git a/frontend/src/hooks/api/secretImports/types.ts b/frontend/src/hooks/api/secretImports/types.ts
index c5d191009c..c231ffe826 100644
--- a/frontend/src/hooks/api/secretImports/types.ts
+++ b/frontend/src/hooks/api/secretImports/types.ts
@@ -16,6 +16,7 @@ export type TSecretImport = {
lastReplicated?: string;
environment?: string;
sourceProjectName?: string;
+ isAccessRevoked?: boolean;
};
export type TGetImportedFoldersByEnvDTO = {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx
index 6b9072465f..47bae57ee1 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretImportTableRow/SecretImportTableRow.tsx
@@ -3,6 +3,7 @@ import { subject } from "@casl/ability";
import { useDragOperation } from "@dnd-kit/react";
import { useSortable } from "@dnd-kit/react/sortable";
import {
+ BanIcon,
ChevronDownIcon,
FolderIcon,
GripVerticalIcon,
@@ -21,6 +22,7 @@ import { ProjectPermissionCan } from "@app/components/permissions";
import {
Badge,
Empty,
+ EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
@@ -105,6 +107,10 @@ export const SecretImportTableRow = ({
? (secretImport ?? getSecretImportByEnv(importEnvSlug, importPath, singleEnvSlug))
: undefined;
+ const isAccessRevoked = isSingleEnvView
+ ? (singleEnvImport?.isAccessRevoked ?? false)
+ : (secretImport?.isAccessRevoked ?? false);
+
const {
ref: sortableRef,
handleRef,
@@ -452,7 +458,28 @@ export const SecretImportTableRow = ({
);
};
+ const renderRevokedContent = () => (
+ <Empty className="gap-3 border-danger/30 bg-danger/5 p-4 text-danger md:p-4">
+ <EmptyHeader className="gap-1.5">
+ <div className="flex items-center gap-2">
+ <TriangleAlertIcon className="size-4 shrink-0" />
+ <EmptyTitle>
+ {secretImport?.sourceProjectName
+ ? `${secretImport.sourceProjectName} revoked access to these secrets.`
+ : "Access to these secrets has been revoked."}
+ </EmptyTitle>
+ </div>
+ <EmptyDescription className="text-danger/70">
+ Imported values can no longer be resolved and any reference to them will fail at build
+ time. Re-request access from the source project, or remove this import.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ );
+
const renderMultiEnvExpandedSecrets = () => {
+ if (isAccessRevoked) return renderRevokedContent();
+
if (hasAnyReplicatedImport) {
const selectedImport = selectedEnvImportData?.secretImportRecord;
@@ -579,6 +606,8 @@ export const SecretImportTableRow = ({
};
const renderExpandedSecrets = (envSlug: string) => {
+ if (isAccessRevoked) return renderRevokedContent();
+
if (filteredImportedSecrets.length === 0) {
return (
<Empty className="bg-transparent shadow-none">
@@ -684,6 +713,19 @@ export const SecretImportTableRow = ({
<FolderIcon className="size-3.5 shrink-0 text-folder" />
<span className="truncate">{importPath}</span>
</div>
+ {isAccessRevoked && (
+ <div
+ className={twMerge(
+ "ml-auto flex items-center",
+ isSingleEnvView && "transition-[margin] duration-300 group-hover:mr-16"
+ )}
+ >
+ <Badge variant="danger">
+ <BanIcon />
+ Access revoked
+ </Badge>
+ </div>
+ )}
{isSingleEnvView &&
singleEnvImport?.isReplication &&
singleEnvImport.lastReplicated && (
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx
index dd35df7016..e113aaec5c 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretImportListView/SecretImportItem.tsx
@@ -21,6 +21,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { EmptyState, IconButton, TableContainer, Tooltip } from "@app/components/v2";
+import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@app/components/v3";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useToggle } from "@app/hooks";
import { useResyncSecretReplication } from "@app/hooks/api";
@@ -83,6 +84,7 @@ export const SecretImportItem = ({
id,
isReplication,
isReplicationSuccess,
+ isAccessRevoked,
replicationStatus,
lastReplicated,
importEnv
@@ -178,6 +180,11 @@ export const SecretImportItem = ({
)}
</div>
<div className="flex items-center space-x-4 py-2 pr-4">
+ {isAccessRevoked && (
+ <span className="rounded border border-red-700/40 bg-red-900/20 px-1.5 py-0.5 text-xs text-red-400">
+ Access revoked
+ </span>
+ )}
{lastReplicated && (
<Tooltip
position="left"
@@ -296,43 +303,66 @@ export const SecretImportItem = ({
colSpan={3}
className={`bg-bunker-800 ${isExpanded && "border-b-2 border-mineshaft-500"}`}
>
- <div className="rounded-md bg-bunker-700 p-1">
- <TableContainer>
- <table className="secret-table">
- <thead>
- <tr>
- <td style={{ padding: "0.25rem 1rem" }}>Key</td>
- <td style={{ padding: "0.25rem 1rem" }}>Value</td>
- </tr>
- </thead>
- <tbody>
- {importedSecrets?.length === 0 && (
- <tr>
- <td colSpan={3}>
- <EmptyState title="No secrets found" icon={faKey} />
- </td>
- </tr>
- )}
- {filteredImportedSecrets.length === 0 && importedSecrets?.length !== 0 && (
+ {isAccessRevoked ? (
+ <div className="p-4">
+ <Empty className="gap-3 border-danger/30 bg-danger/5 p-4 text-danger md:p-4">
+ <EmptyHeader className="gap-1.5">
+ <div className="flex items-center gap-2">
+ <FontAwesomeIcon icon={faWarning} className="size-4 shrink-0" />
+ <EmptyTitle>
+ {secretImport?.sourceProjectName
+ ? `${secretImport.sourceProjectName} revoked access to these secrets.`
+ : "Access to these secrets has been revoked."}
+ </EmptyTitle>
+ </div>
+ <EmptyDescription className="text-danger/70">
+ Imported values can no longer be resolved and any reference to them will fail at
+ build time. Re-request access from the source project, or remove this import.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ </div>
+ ) : (
+ <div className="rounded-md bg-bunker-700 p-1">
+ <TableContainer>
+ <table className="secret-table">
+ <thead>
<tr>
- <td colSpan={3}>
- <EmptyState title="No secrets match search" icon={faSearch} />
- </td>
+ <td style={{ padding: "0.25rem 1rem" }}>Key</td>
+ <td style={{ padding: "0.25rem 1rem" }}>Value</td>
</tr>
- )}
- {filteredImportedSecrets.map((secret, index) => (
- <SecretImportSecretRow
- secret={secret}
- key={`${id}-${secret.key}-${index + 1}`}
- sourceProjectId={
- importEnv.projectId !== currentProject?.id ? importEnv.projectId : undefined
- }
- />
- ))}
- </tbody>
- </table>
- </TableContainer>
- </div>
+ </thead>
+ <tbody>
+ {importedSecrets?.length === 0 && (
+ <tr>
+ <td colSpan={3}>
+ <EmptyState title="No secrets found" icon={faKey} />
+ </td>
+ </tr>
+ )}
+ {filteredImportedSecrets.length === 0 && importedSecrets?.length !== 0 && (
+ <tr>
+ <td colSpan={3}>
+ <EmptyState title="No secrets match search" icon={faSearch} />
+ </td>
+ </tr>
+ )}
+ {filteredImportedSecrets.map((secret, index) => (
+ <SecretImportSecretRow
+ secret={secret}
+ key={`${id}-${secret.key}-${index + 1}`}
+ sourceProjectId={
+ importEnv.projectId !== currentProject?.id
+ ? importEnv.projectId
+ : undefined
+ }
+ />
+ ))}
+ </tbody>
+ </table>
+ </TableContainer>
+ </div>
+ )}
</td>
)}
</>