Skip to content

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

fix(frontend): disable cert manager card for users without access

Tre Dubrava6077ea3b72ae
diff --git a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
index d8853decfe..899da26067 100644
--- a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
@@ -6,7 +6,16 @@ import { createNotification } from "@app/components/notifications";
import { CertManagerNotConfiguredModal } from "@app/components/projects/CertManagerNotConfiguredModal";
import { CertManagerSelectInstanceModal } from "@app/components/projects/CertManagerSelectInstanceModal";
import { RequestProjectAccessModal } from "@app/components/projects/RequestProjectAccessModal";
-import { Card, CardContent, CardDescription, CardHeader, Skeleton } from "@app/components/v3";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ Skeleton,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
import { useOrganization, useOrgPermission } from "@app/context";
import {
OrgPermissionAdminConsoleAction,
@@ -120,6 +129,17 @@ export const ProjectCategoryOverview = () => {
[certManagerInstance?.projects]
);
+ const isOrgAdmin = permission.can(
+ OrgPermissionAdminConsoleAction.AccessAllProjects,
+ OrgPermissionSubjects.AdminConsole
+ );
+ const isCertManagerMember = useMemo(
+ () => cmInstances.some((instance) => projects.some((project) => project.id === instance.id)),
+ [cmInstances, projects]
+ );
+ const isCertManagerAccessBlocked =
+ cmInstances.length > 0 && !isOrgAdmin && !canRequestAccess && !isCertManagerMember;
+
const certManagerActiveProjectId = useMemo(() => {
const cookieValue = currentOrg?.id ? getCertManagerActiveProjectCookie(currentOrg.id) : null;
if (cookieValue && cmInstances.some((p) => p.id === cookieValue)) return cookieValue;
@@ -187,10 +207,6 @@ export const ProjectCategoryOverview = () => {
navigateToCertManager(projectId);
return;
}
- const isOrgAdmin = permission.can(
- OrgPermissionAdminConsoleAction.AccessAllProjects,
- OrgPermissionSubjects.AdminConsole
- );
if (isOrgAdmin) {
try {
await orgAdminAccessProject.mutateAsync({ projectId });
@@ -288,17 +304,8 @@ export const ProjectCategoryOverview = () => {
titleUnderlineClassName
} = PRODUCT_STYLES[type];
- return (
- <Card
- key={type}
- role="button"
- tabIndex={0}
- onClick={() => handleTileClick(type)}
- onKeyDown={(e) => {
- if (e.key === "Enter") handleTileClick(type);
- }}
- className={`group h-auto cursor-pointer rounded-md transition-all duration-200 ease-out hover:scale-[1.01] ${cardClassName}`}
- >
+ const tileBody = (
+ <>
<CardHeader>
<div className="flex items-start gap-3">
<div
@@ -337,6 +344,37 @@ export const ProjectCategoryOverview = () => {
</div>
)}
</CardContent>
+ </>
+ );
+
+ if (type === ProjectType.CertificateManager && isCertManagerAccessBlocked) {
+ return (
+ <Tooltip key={type}>
+ <TooltipTrigger asChild>
+ <div aria-disabled className="cursor-not-allowed">
+ <Card className="h-auto rounded-md opacity-50">{tileBody}</Card>
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ You don&apos;t have access to Certificate Manager. Ask an organization admin for
+ access.
+ </TooltipContent>
+ </Tooltip>
+ );
+ }
+
+ return (
+ <Card
+ key={type}
+ role="button"
+ tabIndex={0}
+ onClick={() => handleTileClick(type)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") handleTileClick(type);
+ }}
+ className={`group h-auto cursor-pointer rounded-md transition-all duration-200 ease-out hover:scale-[1.01] ${cardClassName}`}
+ >
+ {tileBody}
</Card>
);
})}