Skip to content

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

fix(insights): disable the secret folder link for projects the user isn't in

Calvind728c493e2fa
diff --git a/docs/documentation/platform/insights.mdx b/docs/documentation/platform/insights.mdx
index 3d9bfc2c0d..2a9bd8469b 100644
--- a/docs/documentation/platform/insights.mdx
+++ b/docs/documentation/platform/insights.mdx
@@ -56,7 +56,7 @@ Select a project to open that project's Insights page.
The **Duplicated Secrets** card groups secrets that share the same value, across every project in the organization. Each group shows how many secrets share the value and how many projects and locations (an environment and path) they're stored in. Groups that span more than one project are marked with the number of projects.
-Expand a group to see each secret's project, key, environment, and path. To open a secret's folder, hover over its row and select the arrow icon.
+Expand a group to see each secret's project, key, environment, and path. To open a secret's folder, hover over its row and select the arrow icon. If you aren't a member of a secret's project, the arrow icon is disabled.
The card needs two things:
diff --git a/docs/documentation/platform/secret-value-search.mdx b/docs/documentation/platform/secret-value-search.mdx
index 79947ab0ad..b5d7309bc3 100644
--- a/docs/documentation/platform/secret-value-search.mdx
+++ b/docs/documentation/platform/secret-value-search.mdx
@@ -45,7 +45,7 @@ To search for a secret value:
Select the search box, then select **Search by secret value**.
</Step>
<Step>
- Paste the full secret value and select **Search**.
+ Paste the full secret value, then press `Enter` or select **Search**. The search doesn't run as you type.
The value stays masked while you type. To check what you pasted, select the eye icon beside the box. To add a line break to a multi-line value, press `Shift+Enter`.
</Step>
@@ -53,6 +53,8 @@ To search for a secret value:
Review the matches. Each row shows the **Project**, **Secret Key**, **Environment**, and **Path** of a secret that holds the value.
To open a match, hover over its row and select the arrow icon. The project's secrets overview opens at that path, filtered to that environment.
+
+ If you aren't a member of the match's project, the arrow icon is disabled.
</Step>
</Steps>
diff --git a/frontend/src/components/secrets/GoToSecretFolderButton.tsx b/frontend/src/components/secrets/GoToSecretFolderButton.tsx
new file mode 100644
index 0000000000..a95cce7534
--- /dev/null
+++ b/frontend/src/components/secrets/GoToSecretFolderButton.tsx
@@ -0,0 +1,66 @@
+import { useNavigate } from "@tanstack/react-router";
+import { ArrowRightIcon } from "lucide-react";
+
+import {
+ IconButton,
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger
+} from "@app/components/v3";
+
+const overviewRoute =
+ "/organizations/$orgId/projects/secret-management/$projectId/overview" as const;
+
+type Props = {
+ orgId: string;
+ projectId: string;
+ secretPath: string;
+ environmentSlug: string;
+ isProjectMember: boolean;
+ onNavigate?: () => void;
+};
+
+// Org-wide value results include projects the user is not a member of, and the project overview
+// cannot load for them, so the link is disabled rather than sending them to a failing page.
+export const GoToSecretFolderButton = ({
+ orgId,
+ projectId,
+ secretPath,
+ environmentSlug,
+ isProjectMember,
+ onNavigate
+}: Props) => {
+ const navigate = useNavigate();
+
+ return (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ {/* A disabled button fires no pointer events, so the span carries the tooltip hover. */}
+ <span className="inline-flex opacity-0 transition-opacity group-hover/row:opacity-100 focus-within:opacity-100">
+ <IconButton
+ variant="ghost"
+ size="sm"
+ aria-label="Go to secret folder"
+ isDisabled={!isProjectMember}
+ onClick={() => {
+ onNavigate?.();
+ navigate({
+ to: overviewRoute,
+ params: { orgId, projectId },
+ search: { secretPath, environments: [environmentSlug] }
+ });
+ }}
+ >
+ <ArrowRightIcon className="size-3.5" />
+ </IconButton>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ {isProjectMember ? "Go to secret folder" : "You don't have access to this project"}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ );
+};
diff --git a/frontend/src/components/secrets/SecretValueSearchSheet.tsx b/frontend/src/components/secrets/SecretValueSearchSheet.tsx
index 90e0779af6..f389b1752e 100644
--- a/frontend/src/components/secrets/SecretValueSearchSheet.tsx
+++ b/frontend/src/components/secrets/SecretValueSearchSheet.tsx
@@ -1,6 +1,5 @@
-import { FormEvent, useState } from "react";
-import { useNavigate } from "@tanstack/react-router";
-import { ArrowRightIcon, EyeIcon, EyeOffIcon, FolderIcon, KeyIcon } from "lucide-react";
+import { FormEvent, useMemo, useState } from "react";
+import { EyeIcon, EyeOffIcon, FolderIcon, KeyIcon } from "lucide-react";
import {
Badge,
@@ -23,22 +22,17 @@ import {
TableCell,
TableHead,
TableHeader,
- TableRow,
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger
+ TableRow
} from "@app/components/v3";
+import { useGetUserProjects } from "@app/hooks/api";
import { useSearchSecretsByValue } from "@app/hooks/api/secretInsights";
+import { GoToSecretFolderButton } from "./GoToSecretFolderButton";
import { SecretValueTrackingPrompt, useOrgSecretValueTracking } from "./SecretValueTrackingGate";
// Mirrors SECRET_VALUE_SEARCH_LIMIT on the server, which truncates without saying so.
const SEARCH_RESULT_LIMIT = 1000;
-const overviewRoute =
- "/organizations/$orgId/projects/secret-management/$projectId/overview" as const;
-
type Props = {
orgId: string;
isOpen: boolean;
@@ -46,10 +40,14 @@ type Props = {
};
const SearchContent = ({ orgId, onClose }: { orgId: string; onClose: () => void }) => {
- const navigate = useNavigate();
const [value, setValue] = useState("");
const [isRevealed, setIsRevealed] = useState(false);
const search = useSearchSecretsByValue();
+ const { data: memberProjects } = useGetUserProjects();
+ const memberProjectIds = useMemo(
+ () => new Set(memberProjects?.map((project) => project.id)),
+ [memberProjects]
+ );
const tracking = useOrgSecretValueTracking({ orgId, enabled: true });
@@ -80,7 +78,7 @@ const SearchContent = ({ orgId, onClose }: { orgId: string; onClose: () => void
return (
<Empty variant="unstyled">
<EmptyHeader>
- <EmptyTitle>Enter a secret value to find where it is used</EmptyTitle>
+ <EmptyTitle>Paste a secret value, then press Enter or select Search</EmptyTitle>
<EmptyDescription>
Results cover every project in the organization, including ones you are not a member
of.
@@ -149,32 +147,14 @@ const SearchContent = ({ orgId, onClose }: { orgId: string; onClose: () => void
</div>
</TableCell>
<TableCell variant="action">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- variant="ghost"
- size="sm"
- aria-label="Go to secret folder"
- className="opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100"
- onClick={() => {
- onClose();
- navigate({
- to: overviewRoute,
- params: { orgId, projectId: match.projectId },
- search: {
- secretPath: match.secretPath,
- environments: [match.environment.slug]
- }
- });
- }}
- >
- <ArrowRightIcon className="size-3.5" />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Go to secret folder</TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <GoToSecretFolderButton
+ orgId={orgId}
+ projectId={match.projectId}
+ secretPath={match.secretPath}
+ environmentSlug={match.environment.slug}
+ isProjectMember={memberProjectIds.has(match.projectId)}
+ onNavigate={onClose}
+ />
</TableCell>
</TableRow>
))}
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/DuplicateGroupList.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/DuplicateGroupList.tsx
index ab87a5ed2a..ab2ee02fe1 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/DuplicateGroupList.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/DuplicateGroupList.tsx
@@ -1,31 +1,26 @@
-import { useNavigate, useParams } from "@tanstack/react-router";
-import { ArrowRightIcon, FolderIcon, KeyIcon, LayersIcon, LockIcon } from "lucide-react";
+import { useMemo } from "react";
+import { useParams } from "@tanstack/react-router";
+import { FolderIcon, KeyIcon, LayersIcon, LockIcon } from "lucide-react";
+import { GoToSecretFolderButton } from "@app/components/secrets/GoToSecretFolderButton";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
Badge,
- IconButton,
ProjectIcon,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
- TableRow,
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger
+ TableRow
} from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
+import { useGetUserProjects } from "@app/hooks/api";
import { TOrgDuplicatedSecretGroup } from "@app/hooks/api/secretInsights";
-const overviewRoute =
- "/organizations/$orgId/projects/secret-management/$projectId/overview" as const;
-
type Props = {
groups: TOrgDuplicatedSecretGroup[];
};
@@ -34,7 +29,11 @@ const pluralize = (count: number, word: string) => `${count} ${word}${count ===
export const DuplicateGroupList = ({ groups }: Props) => {
const { orgId } = useParams({ strict: false });
- const navigate = useNavigate();
+ const { data: memberProjects } = useGetUserProjects();
+ const memberProjectIds = useMemo(
+ () => new Set(memberProjects?.map((project) => project.id)),
+ [memberProjects]
+ );
return (
<Accordion type="multiple">
@@ -108,34 +107,13 @@ export const DuplicateGroupList = ({ groups }: Props) => {
</div>
</TableCell>
<TableCell variant="action">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- variant="ghost"
- size="sm"
- aria-label="Go to secret folder"
- className="opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100"
- onClick={() =>
- navigate({
- to: overviewRoute,
- params: {
- orgId: orgId as string,
- projectId: entry.projectId
- },
- search: {
- secretPath: entry.secretPath,
- environments: [entry.environment.slug]
- }
- })
- }
- >
- <ArrowRightIcon className="size-3.5" />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Go to secret folder</TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <GoToSecretFolderButton
+ orgId={orgId as string}
+ projectId={entry.projectId}
+ secretPath={entry.secretPath}
+ environmentSlug={entry.environment.slug}
+ isProjectMember={memberProjectIds.has(entry.projectId)}
+ />
</TableCell>
</TableRow>
))}