Skip to content

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

improvement: harden org nav tab handling and restrict SSO to root org

Scott Wilsonb07009a5dd9f
diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts
index b2a73bb1bd..fa7b0f743c 100644
--- a/frontend/src/helpers/project.ts
+++ b/frontend/src/helpers/project.ts
@@ -85,6 +85,14 @@ export const urlSlugToProjectType = (slug: string): ProjectType | null => {
return slug as ProjectType;
};
+// Org-wide resource pages (KMIP servers, Secret Sharing) live at literal
+// /projects/<slug>/<resource> paths with no $type route param. Parse the product slug out of the
+// pathname so the sidebar can resolve the active product when the route param is absent.
+const ORG_RESOURCE_PROJECT_SLUG_RE = /\/projects\/([^/]+)\/(?:kmip-servers|secret-sharing)/;
+
+export const parseProjectSlugFromPath = (pathname: string): string | undefined =>
+ pathname.match(ORG_RESOURCE_PROJECT_SLUG_RE)?.[1];
+
const PROJECT_TYPES_WITH_INTERMEDIATE_VIEW = new Set<ProjectType>([
ProjectType.SecretManager,
ProjectType.KMS,
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
index 9158b6800d..fa4611ad70 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
@@ -2,7 +2,11 @@ import { useLocation, useParams } from "@tanstack/react-router";
import { Sidebar, SidebarContent, SidebarFooter, SidebarTrigger } from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { hasIntermediateProjectsView, urlSlugToProjectType } from "@app/helpers/project";
+import {
+ hasIntermediateProjectsView,
+ parseProjectSlugFromPath,
+ urlSlugToProjectType
+} from "@app/helpers/project";
import { OrgNav } from "./OrgNav";
import { ProjectNav } from "./ProjectNav";
@@ -20,10 +24,9 @@ export const OrgSidebar = () => {
});
const { pathname } = useLocation();
const isInsideProject = Boolean(projectId);
- // The org-wide KMIP servers and Secret Sharing pages live at literal /projects/<type>/<resource>
+ // The org-wide KMIP servers and Secret Sharing pages live at literal /projects/<slug>/<resource>
// paths with no $type route param, so fall back to parsing the product slug from the pathname.
- const effectiveTypeSlug =
- typeSlug ?? pathname.match(/\/projects\/([^/]+)\/(?:kmip-servers|secret-sharing)/)?.[1];
+ const effectiveTypeSlug = typeSlug ?? parseProjectSlugFromPath(pathname);
const projectType = effectiveTypeSlug ? urlSlugToProjectType(effectiveTypeSlug) : null;
const isOnProjectTypeListing =
!isInsideProject && Boolean(projectType) && hasIntermediateProjectsView(projectType!);
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
index ccfd5d9b8a..b004aa0714 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
@@ -10,7 +10,7 @@ import {
SidebarMenuItem
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { urlSlugToProjectType } from "@app/helpers/project";
+import { parseProjectSlugFromPath, urlSlugToProjectType } from "@app/helpers/project";
import { ProjectType } from "@app/hooks/api/projects/types";
export const ProjectTypeNav = () => {
@@ -24,8 +24,7 @@ export const ProjectTypeNav = () => {
// KMIP servers and Secret Sharing live at literal /projects/<slug>/<resource> paths (no $type
// param), so fall back to parsing the product slug out of the pathname when it's absent.
- const typeSlug =
- paramTypeSlug ?? pathname.match(/\/projects\/([^/]+)\/(?:kmip-servers|secret-sharing)/)?.[1];
+ const typeSlug = paramTypeSlug ?? parseProjectSlugFromPath(pathname);
const isKms = typeSlug === ProjectType.KMS;
// Secret Manager's URL slug ("secret-management") differs from the enum value ("secret-manager"),
// so resolve through the helper rather than comparing the slug directly.
diff --git a/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx b/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
index c63d4929fb..01b09312cd 100644
--- a/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
@@ -76,7 +76,10 @@ export const AccessManagementPage = () => {
const visibleTabSections = tabSections.filter((el) => !el.isHidden);
const selectedTabSection = tabSections.find((tab) => tab.key === selectedTab);
- const isSelectedTabRestricted = !selectedTabSection || selectedTabSection.isHidden;
+ // A tab that exists but is permission-hidden is restricted (show the guard banner); an unknown
+ // tab falls back to the first visible tab instead of showing the banner.
+ const isSelectedTabRestricted = Boolean(selectedTabSection?.isHidden);
+ const activeTab = selectedTabSection ? selectedTab : (visibleTabSections[0]?.key ?? selectedTab);
return (
<div className="mx-auto flex flex-col justify-between bg-bunker-800 text-white">
@@ -129,7 +132,7 @@ export const AccessManagementPage = () => {
{visibleTabSections.length === 0 ? (
<OrgPermissionGuardBanner />
) : (
- <Tabs value={selectedTab} onValueChange={updateSelectedTab}>
+ <Tabs value={activeTab} onValueChange={updateSelectedTab}>
<TabList>
{visibleTabSections.map(({ key, label }) => (
<Tab
diff --git a/frontend/src/pages/organization/AuditLogsPage/route.tsx b/frontend/src/pages/organization/AuditLogsPage/route.tsx
index a54c14fbcf..6becd0c1c5 100644
--- a/frontend/src/pages/organization/AuditLogsPage/route.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/route.tsx
@@ -1,11 +1,11 @@
-import { createFileRoute, stripSearchParams } from "@tanstack/react-router";
+import { createFileRoute } from "@tanstack/react-router";
import { zodValidator } from "@tanstack/zod-adapter";
import { z } from "zod";
import { AuditLogsPage } from "./AuditLogsPage";
const AuditLogsPageQueryParams = z.object({
- selectedTab: z.string().catch("").default("audit-logs")
+ selectedTab: z.string().catch("audit-logs")
});
export const Route = createFileRoute(
@@ -13,9 +13,6 @@ export const Route = createFileRoute(
)({
component: AuditLogsPage,
validateSearch: zodValidator(AuditLogsPageQueryParams),
- search: {
- middlewares: [stripSearchParams({ selectedTab: "" })]
- },
context: () => ({
breadcrumbs: [
{
diff --git a/frontend/src/pages/organization/IntegrationsPage/route.tsx b/frontend/src/pages/organization/IntegrationsPage/route.tsx
index 9828960232..59503cba51 100644
--- a/frontend/src/pages/organization/IntegrationsPage/route.tsx
+++ b/frontend/src/pages/organization/IntegrationsPage/route.tsx
@@ -1,4 +1,4 @@
-import { createFileRoute } from "@tanstack/react-router";
+import { createFileRoute, stripSearchParams } from "@tanstack/react-router";
import { zodValidator } from "@tanstack/zod-adapter";
import { z } from "zod";
@@ -8,7 +8,7 @@ import { IntegrationsListPageTabs } from "@app/types/integrations";
import { IntegrationsPage } from "./IntegrationsPage";
const IntegrationsPageQuerySchema = z.object({
- selectedTab: z.string().catch(IntegrationsListPageTabs.AppConnections),
+ selectedTab: z.string().catch("").default(IntegrationsListPageTabs.AppConnections),
error: z.string().optional(),
success: z.string().optional(),
connectionId: z.string().optional(),
@@ -21,6 +21,9 @@ export const Route = createFileRoute(
)({
component: IntegrationsPage,
validateSearch: zodValidator(IntegrationsPageQuerySchema),
+ search: {
+ middlewares: [stripSearchParams({ selectedTab: "" })]
+ },
context: () => ({
breadcrumbs: [
{
diff --git a/frontend/src/pages/organization/SsoPage/route.tsx b/frontend/src/pages/organization/SsoPage/route.tsx
index ac47525e32..3a475aad35 100644
--- a/frontend/src/pages/organization/SsoPage/route.tsx
+++ b/frontend/src/pages/organization/SsoPage/route.tsx
@@ -1,11 +1,13 @@
-import { createFileRoute } from "@tanstack/react-router";
+import { createFileRoute, redirect, stripSearchParams } from "@tanstack/react-router";
import { zodValidator } from "@tanstack/zod-adapter";
import { z } from "zod";
+import { fetchOrganizationById, organizationKeys } from "@app/hooks/api/organization/queries";
+
import { SsoPage } from "./SsoPage";
const SsoPageQuerySchema = z.object({
- selectedTab: z.string().catch("sso")
+ selectedTab: z.string().catch("").default("sso")
});
export const Route = createFileRoute(
@@ -13,11 +15,29 @@ export const Route = createFileRoute(
)({
component: SsoPage,
validateSearch: zodValidator(SsoPageQuerySchema),
- context: () => ({
- breadcrumbs: [
- {
- label: "SSO & Provisioning"
- }
- ]
- })
+ search: {
+ middlewares: [stripSearchParams({ selectedTab: "" })]
+ },
+ beforeLoad: async ({ context, params }) => {
+ const org = await context.queryClient.ensureQueryData({
+ queryKey: organizationKeys.getOrgById(context.organizationId),
+ queryFn: () => fetchOrganizationById(context.organizationId)
+ });
+
+ // SSO/SCIM config is root-org only; sub-orgs must not reach it via direct URL or moved-tab redirects.
+ if (org.rootOrgId && org.id !== org.rootOrgId) {
+ throw redirect({
+ to: "/organizations/$orgId/settings",
+ params: { orgId: params.orgId }
+ });
+ }
+
+ return {
+ breadcrumbs: [
+ {
+ label: "SSO & Provisioning"
+ }
+ ]
+ };
+ }
});