Skip to content

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

misc: comments

Sheen Capadngand0a3ba945ab1
diff --git a/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx b/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
index 6893bdfea2..8dfa3a1b6f 100644
--- a/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
+++ b/frontend/src/components/v3/platform/RootCommandMenu/RootCommandMenu.tsx
@@ -67,9 +67,10 @@ import {
} from "@app/context/ProjectPermissionContext/types";
import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
import { getOrganizationSwitchDestination } from "@app/helpers/organizationSwitch";
-import { getProjectLucideIcon, getProjectTitle } from "@app/helpers/project";
+import { getProjectDisplayName, getProjectLucideIcon, getProjectTitle } from "@app/helpers/project";
import { useImplicitProduct } from "@app/hooks";
import { useGetOrganizationGroups, useGetOrganizationsWithSubOrgs } from "@app/hooks/api";
+import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
import { useGetAccessibleProjectsWithSubOrgs } from "@app/hooks/api/projects/queries";
import type { Project, TProjectNavigation } from "@app/hooks/api/projects/types";
import { ProjectType } from "@app/hooks/api/projects/types";
@@ -163,10 +164,6 @@ const NavigationCommandMenu = ({
);
};
-// Certificate Manager has no user-facing projects, so it is named after the product.
-const getProjectDisplayName = (project: Pick<Project, "name" | "type">) =>
- project.type === ProjectType.CertificateManager ? getProjectTitle(project.type) : project.name;
-
const navigateToProject = (
navigate: ReturnType<typeof useNavigate>,
project: TProjectNavigation
@@ -241,6 +238,14 @@ const useEntityCommandGroups = ({
organizations.map((organization) => [organization.id, organization])
);
+ const certManagerProjectCountByOrg = projects.reduce<Record<string, number>>(
+ (counts, project) =>
+ project.type === ProjectType.CertificateManager
+ ? { ...counts, [project.orgId]: (counts[project.orgId] ?? 0) + 1 }
+ : counts,
+ {}
+ );
+
const projectItems: GlobalCommandMenuItem[] = projects.map((project) => {
const organization = organizationsById.get(project.orgId);
const organizationPath = [
@@ -252,7 +257,7 @@ const useEntityCommandGroups = ({
return {
id: `entity-project-${project.id}`,
- label: getProjectDisplayName(project),
+ label: getProjectDisplayName(project, (certManagerProjectCountByOrg[project.orgId] ?? 0) > 1),
breadcrumb: `${organizationPath} / ${getProjectTitle(project.type)}`,
icon: getProjectLucideIcon(project.type),
iconClassName: projectIconClassNames[project.type],
@@ -710,14 +715,16 @@ const getProjectLandingItem = ({
navigate,
project,
organizationName,
- isCertificateManagerAdmin
+ isCertificateManagerAdmin,
+ isCertManagerMultiInstance = false
}: {
navigate: ReturnType<typeof useNavigate>;
project: Project;
organizationName: string;
isCertificateManagerAdmin?: boolean;
+ isCertManagerMultiInstance?: boolean;
}): GlobalCommandMenuItem => {
- const breadcrumb = `${organizationName} / ${getProjectDisplayName(project)}`;
+ const breadcrumb = `${organizationName} / ${getProjectDisplayName(project, isCertManagerMultiInstance)}`;
if (project.type === ProjectType.CertificateManager && !isCertificateManagerAdmin) {
return {
@@ -763,15 +770,17 @@ const getProjectPageItems = ({
project,
organizationName,
pathname,
- isCertificateManagerAdmin
+ isCertificateManagerAdmin,
+ isCertManagerMultiInstance = false
}: {
navigate: ReturnType<typeof useNavigate>;
project: Project;
organizationName: string;
pathname: string;
isCertificateManagerAdmin?: boolean;
+ isCertManagerMultiInstance?: boolean;
}): GlobalCommandMenuItem[] => {
- const breadcrumb = `${organizationName} / ${getProjectDisplayName(project)}`;
+ const breadcrumb = `${organizationName} / ${getProjectDisplayName(project, isCertManagerMultiInstance)}`;
const item = (
id: string,
label: string,
@@ -890,7 +899,8 @@ const getProjectPageItems = ({
navigate,
project,
organizationName,
- isCertificateManagerAdmin
+ isCertificateManagerAdmin,
+ isCertManagerMultiInstance
});
if (!isCertificateManagerAdmin) return [landing];
return sortByContext([
@@ -1002,29 +1012,30 @@ const CertificateProjectCommandMenu = ({
const { currentProject } = useProject();
const navigate = useNavigate();
const { pathname } = useLocation();
+ const { data: certManagerInstance } = useCertManagerInstanceState();
+ const isCertManagerMultiInstance = Boolean(certManagerInstance?.isMultiInstance);
const projectItems = filterProjectPageItems(
getProjectPageItems({
navigate,
project: currentProject,
organizationName: currentOrg.name,
pathname,
- isCertificateManagerAdmin: hasProjectRole("admin")
+ isCertificateManagerAdmin: hasProjectRole("admin"),
+ isCertManagerMultiInstance
}),
permission
);
+ const menuHeading = getProjectDisplayName(currentProject, isCertManagerMultiInstance);
return (
<NavigationCommandMenu
shell="organization"
searchStatus={content.searchStatus}
browseGroups={[
- { heading: getProjectTitle(currentProject.type), items: projectItems.slice(0, 2) },
+ { heading: menuHeading, items: projectItems.slice(0, 2) },
...content.browseGroups
]}
- searchGroups={[
- { heading: getProjectTitle(currentProject.type), items: projectItems },
- ...content.searchGroups
- ]}
+ searchGroups={[{ heading: menuHeading, items: projectItems }, ...content.searchGroups]}
/>
);
};
diff --git a/frontend/src/config/request.ts b/frontend/src/config/request.ts
index a3ba41bdb3..0260e27df9 100644
--- a/frontend/src/config/request.ts
+++ b/frontend/src/config/request.ts
@@ -4,6 +4,7 @@ import { addSeconds, formatISO } from "date-fns";
import { createNotification } from "@app/components/notifications";
import SecurityClient from "@app/components/utilities/SecurityClient";
import { SessionStorageKeys } from "@app/const";
+import { getTabCertManagerProjectIdForRequest } from "@app/helpers/certManagerActiveProject";
import { fetchAuthToken } from "@app/hooks/api/auth/refresh";
import {
getAuthToken,
@@ -20,6 +21,17 @@ export const apiRequest = axios.create({
});
apiRequest.interceptors.request.use((config) => {
+ const tabProjectId = getTabCertManagerProjectIdForRequest(config.url);
+ const body = config.data as { projectId?: unknown } | undefined;
+ const namesProject =
+ Boolean((config.params as { projectId?: unknown } | undefined)?.projectId) ||
+ Boolean(config.url?.includes("projectId=")) ||
+ (typeof body === "object" && body !== null && "projectId" in body);
+ if (tabProjectId && !namesProject) {
+ // eslint-disable-next-line no-param-reassign
+ config.params = { ...config.params, projectId: tabProjectId };
+ }
+
// Skip auto-injection if the caller already set an Authorization header
if (config.headers?.Authorization) return config;
diff --git a/frontend/src/helpers/certManagerActiveProject.ts b/frontend/src/helpers/certManagerActiveProject.ts
index 6c1f4d36fd..fd32e4a1bd 100644
--- a/frontend/src/helpers/certManagerActiveProject.ts
+++ b/frontend/src/helpers/certManagerActiveProject.ts
@@ -33,3 +33,23 @@ export const resolveCertManagerProjectId = ({
if (pinnedProjectId && memberProjectIds.includes(pinnedProjectId)) return pinnedProjectId;
return activeProjectId;
};
+
+// The cookie is shared by every tab, and the backend falls back to it for requests that name no
+// project. In an org with several instances, a tab that switched instances would then redirect another
+// tab's writes (an inventory import would store a private key in the wrong instance), so each tab names
+// the instance it is showing. Single-instance orgs pass null and keep sending no project.
+let tabCertManagerProjectId: string | null = null;
+
+export const setTabCertManagerProjectId = (projectId: string | null) => {
+ tabCertManagerProjectId = projectId;
+};
+
+const CERT_MANAGER_API_PREFIXES = ["/api/v1/cert-manager/", "/api/v1/pki/", "/api/v2/pki/"];
+const CERT_MANAGER_PAGE_RE = /^\/organizations\/[^/]+\/cert-manager(\/|$)/;
+
+export const getTabCertManagerProjectIdForRequest = (url: string | undefined): string | null => {
+ if (!tabCertManagerProjectId || !url) return null;
+ if (!CERT_MANAGER_API_PREFIXES.some((prefix) => url.startsWith(prefix))) return null;
+ if (!CERT_MANAGER_PAGE_RE.test(window.location.pathname)) return null;
+ return tabCertManagerProjectId;
+};
diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts
index bc286cf0cb..2ffe554c1a 100644
--- a/frontend/src/helpers/project.ts
+++ b/frontend/src/helpers/project.ts
@@ -193,6 +193,16 @@ export const getProjectTitle = (type: ProjectType) => {
return titleConvert[type] || type;
};
+// Certificate Manager is named after the product, except in legacy orgs that still have several
+// instances, where the instance name is the only thing telling them apart.
+export const getProjectDisplayName = (
+ project: Pick<Project, "name" | "type">,
+ isCertManagerMultiInstance: boolean
+) =>
+ project.type === ProjectType.CertificateManager && !isCertManagerMultiInstance
+ ? getProjectTitle(project.type)
+ : project.name;
+
export const getProjectDescription = (type: ProjectType) => {
const descriptions: Partial<Record<ProjectType, string>> = {
[ProjectType.SecretManager]:
diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts
index fe9ecfd9bc..385bd48978 100644
--- a/frontend/src/hooks/index.ts
+++ b/frontend/src/hooks/index.ts
@@ -8,7 +8,6 @@ export { useDiscardChangesGuard } from "./useDiscardChangesGuard";
export * from "./useGetProjectTypeFromRoute";
export { useImplicitProduct } from "./useImplicitProduct";
export { useImplicitProjectId } from "./useImplicitProjectId";
-export { useRouteProjectId } from "./useRouteProjectId";
export { useLastLogin } from "./useLastLogin";
export { useLocalStorageState } from "./useLocalStorageState";
export { useOnboarding } from "./useOnboarding";
@@ -18,6 +17,7 @@ export { usePopUp } from "./usePopUp";
export { useResetPageHelper } from "./useResetPageHelper";
export { useResetPageOnSearch } from "./useResetPageOnSearch";
export * from "./useResizableHeaderHeight";
+export { useRouteProjectId } from "./useRouteProjectId";
export { useScopeVariant } from "./useScopeVariant";
export { useSecretsActivationNudge } from "./useSecretsActivationNudge";
export { useSlashFocusSearch } from "./useSlashFocusSearch";
diff --git a/frontend/src/pages/cert-manager/layout.tsx b/frontend/src/pages/cert-manager/layout.tsx
index f7803de9d7..8f8da161a4 100644
--- a/frontend/src/pages/cert-manager/layout.tsx
+++ b/frontend/src/pages/cert-manager/layout.tsx
@@ -2,7 +2,8 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
import {
resolveCertManagerProjectId,
- setCertManagerActiveProjectCookie
+ setCertManagerActiveProjectCookie,
+ setTabCertManagerProjectId
} from "@app/helpers/certManagerActiveProject";
import { projectKeys } from "@app/hooks/api";
import {
@@ -54,6 +55,7 @@ export const Route = createFileRoute(
// Requests that name no project resolve from this cookie on the backend, so keep it on the
// project the UI is showing, including when a stale or inaccessible one was ignored above.
setCertManagerActiveProjectCookie(params.orgId, projectId);
+ setTabCertManagerProjectId(instance.isMultiInstance ? projectId : null);
const previousProjectId = resolvedProjectIdByOrg.get(params.orgId);
resolvedProjectIdByOrg.set(params.orgId, projectId);
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
index f3168a889d..c161147072 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -52,7 +52,7 @@ import {
} from "@app/components/v3";
import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context";
import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
-import { getProjectBaseURL, getProjectTitle } from "@app/helpers/project";
+import { getProjectBaseURL, getProjectDisplayName } from "@app/helpers/project";
import {
getUserTablePreference,
PreferenceKey,
@@ -65,6 +65,7 @@ import {
useCountOrgIdentityMemberships,
useSearchOrgIdentityMemberships
} from "@app/hooks/api";
+import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { IdentityMembershipSearchResult, SearchIdentitiesScope } from "@app/hooks/api/identities";
import { OrgIdentityOrderBy } from "@app/hooks/api/organization/types";
@@ -138,13 +139,15 @@ const ManagedByCell = ({
isSubOrganization,
isSubOrgIdentity
}: ManagedByCellProps) => {
+ const { data: certManagerInstance } = useCertManagerInstanceState();
+
if (scope === SearchIdentitiesScope.ProjectScope) {
return (
<Badge variant="project">
<ProjectIcon />
- {project?.type === ProjectType.CertificateManager
- ? getProjectTitle(project.type)
- : (project?.name ?? "Project")}
+ {project
+ ? getProjectDisplayName(project, Boolean(certManagerInstance?.isMultiInstance))
+ : "Project"}
</Badge>
);
}
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
index 0271ff63b1..c80e60703d 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
@@ -42,10 +42,11 @@ import {
getAppConnectionMethodDetails
} from "@app/helpers/appConnections";
import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
-import { getProjectBaseURL, getProjectTitle } from "@app/helpers/project";
+import { getProjectBaseURL, getProjectDisplayName } from "@app/helpers/project";
import { useToggle } from "@app/hooks";
import { GitHubConnectionMethod, TAppConnection } from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
import { useListGitHubApps } from "@app/hooks/api/gitHubApps";
import { ProjectType } from "@app/hooks/api/projects/types";
@@ -71,6 +72,7 @@ export const AppConnectionRow = ({
isProjectView
}: Props) => {
const { currentOrg } = useOrganization();
+ const { data: certManagerInstance } = useCertManagerInstanceState();
const {
id,
name,
@@ -216,9 +218,7 @@ export const AppConnectionRow = ({
>
<p className="flex items-center gap-1.5 truncate">
<ProjectIcon className="size-3.5 text-label/75" />
- {project.type === ProjectType.CertificateManager
- ? getProjectTitle(project.type)
- : project.name}
+ {getProjectDisplayName(project, Boolean(certManagerInstance?.isMultiInstance))}
</p>
</Link>
) : (
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx b/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
index 25cd62f9c1..952da261fb 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
@@ -20,7 +20,7 @@ import {
Separator
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { getProjectTitle, isOrgScopedProduct } from "@app/helpers/project";
+import { getProjectDisplayName, isOrgScopedProduct } from "@app/helpers/project";
import { useScopeVariant } from "@app/hooks";
import { useGetUserProjects } from "@app/hooks/api";
import {
@@ -89,6 +89,8 @@ export const LogsFilter = ({ presets, setFilter, filter, project }: Props) => {
const scopeVariant = useScopeVariant();
const workspacesInOrg = workspaces.filter((ws) => ws.orgId === currentOrg?.id);
+ const isCertManagerMultiInstance =
+ workspacesInOrg.filter((ws) => ws.type === ProjectType.CertificateManager).length > 1;
const { control, watch, setValue, handleSubmit, formState } = useForm<TAuditLogFilterFormData>({
resolver: zodResolver(auditLogFilterFormSchema),
@@ -298,9 +300,7 @@ export const LogsFilter = ({ presets, setFilter, filter, project }: Props) => {
}))}
getOptionValue={(option) => option.id}
getOptionLabel={(option) =>
- option.type === ProjectType.CertificateManager
- ? getProjectTitle(option.type)
- : option.name
+ getProjectDisplayName(option, isCertManagerMultiInstance)
}
isError={Boolean(error)}
/>
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
index 184adf740e..8447d16b6a 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
@@ -25,6 +25,7 @@ import {
} from "@app/components/v3";
import { useOrganization } from "@app/context";
import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
+import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
import {
TGatewayConnectedResources,
useGetGatewayConnectedResources
@@ -71,6 +72,7 @@ const ResourceRow = ({
export const GatewayConnectedResourcesSection = ({ gatewayId }: Props) => {
const { currentOrg } = useOrganization();
const { data: resources, isPending } = useGetGatewayConnectedResources(gatewayId);
+ const { data: certManagerInstance } = useCertManagerInstanceState();
const total = totalCountOf(resources);
@@ -234,7 +236,11 @@ export const GatewayConnectedResourcesSection = ({ gatewayId }: Props) => {
<ResourceRow
key={c.id}
name={c.name}
- subtitle="Certificate Manager"
+ subtitle={
+ certManagerInstance?.isMultiInstance
+ ? c.projectName
+ : "Certificate Manager"
+ }
to="/organizations/$orgId/cert-manager/discovery/$discoveryId"
params={{ orgId: currentOrg.id, discoveryId: c.id }}
onClick={() =>
diff --git a/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx b/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
index 7d185ccdfd..71cee9fca5 100644
--- a/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
+++ b/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
@@ -5,9 +5,9 @@ import {
useProject,
useProjectPermission
} from "@app/context";
+import { getProjectTitle, isOrgScopedProduct } from "@app/helpers/project";
import { useScopeVariant } from "@app/hooks";
import { useGetProjectAuditLogSettings, useUpdateProjectAuditLogSettings } from "@app/hooks/api";
-import { ProjectType } from "@app/hooks/api/projects/types";
export const AuditLogEventClassesSection = () => {
const { currentProject } = useProject();
@@ -25,8 +25,8 @@ export const AuditLogEventClassesSection = () => {
<AuditLogEventClassesForm
title="Event Classes"
description={
- currentProject.type === ProjectType.CertificateManager
- ? "Choose which classes of Certificate Manager events are recorded."
+ isOrgScopedProduct(currentProject.type)
+ ? `Choose which classes of ${getProjectTitle(currentProject.type)} events are recorded.`
: "Choose which classes of events this project records."
}
settings={settings}
diff --git a/frontend/src/pages/project/AuditLogsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx b/frontend/src/pages/project/AuditLogsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx
index e6627c9ca0..0c9a19e499 100644
--- a/frontend/src/pages/project/AuditLogsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx
+++ b/frontend/src/pages/project/AuditLogsPage/components/AuditLogsRetentionSection/AuditLogsRetentionSection.tsx
@@ -25,9 +25,9 @@ import {
useSubscription
} from "@app/context";
import { isInfisicalCloud } from "@app/helpers/platform";
+import { getProjectTitle, isOrgScopedProduct } from "@app/helpers/project";
import { usePopUp } from "@app/hooks";
import { useUpdateWorkspaceAuditLogsRetention } from "@app/hooks/api/projects/queries";
-import { ProjectType } from "@app/hooks/api/projects/types";
const formSchema = z.object({
auditLogsRetentionDays: z.coerce.number().min(0)
@@ -99,8 +99,8 @@ export const AuditLogsRetentionSection = () => {
<CardHeader>
<CardTitle>Audit Logs Retention</CardTitle>
<CardDescription>
- {currentProject.type === ProjectType.CertificateManager
- ? "Set the number of days to keep your Certificate Manager audit logs."
+ {isOrgScopedProduct(currentProject.type)
+ ? `Set the number of days to keep your ${getProjectTitle(currentProject.type)} audit logs.`
: "Set the number of days to keep your project audit logs."}
</CardDescription>
</CardHeader>
diff --git a/frontend/src/pages/redirects/cert-manager-project-url-redirect.tsx b/frontend/src/pages/redirects/cert-manager-project-url-redirect.tsx
index 3354e9551f..d3c2ebc1ec 100644
--- a/frontend/src/pages/redirects/cert-manager-project-url-redirect.tsx
+++ b/frontend/src/pages/redirects/cert-manager-project-url-redirect.tsx
@@ -16,7 +16,8 @@ export const Route = createFileRoute(
}
// _splat arrives decoded, and a trailing slash leaves an empty segment behind.
- const rest = (params._splat ?? "")
+ const { _splat: splat } = params;
+ const rest = (splat ?? "")
.split("/")
.filter(Boolean)
.map((segment) => `/${encodeURIComponent(segment)}`)