Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
PR comments
Matheus Nogueira3e19acd16480
diff --git a/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-router.ts b/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-router.tsindex b377ceddf3..cc9196b40e 100644--- a/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-router.ts+++ b/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-router.ts@@ -17,7 +17,8 @@ import {ApiDocsTags,SecretScanningConfigs,SecretScanningDataSources,- SecretScanningFindings+ SecretScanningFindings,+ SecretScanningProjects} from "@app/lib/api-docs";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";@@ -44,7 +45,7 @@ export const registerSecretScanningV2Router = async (server: FastifyZodProvider)tags: [ApiDocsTags.SecretScanning],description: "Resolve the organization's active Secret Scanning project, creating it on first access.",response: {- 200: z.object({ projectId: z.string() })+ 200: z.object({ projectId: z.string().describe(SecretScanningProjects.GET_ACTIVE.projectId) })}},onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),@@ -72,16 +73,17 @@ export const registerSecretScanningV2Router = async (server: FastifyZodProvider)description: "Get the active Secret Scanning project and every Secret Scanning project in the organization.",response: {200: z.object({- activeProjectId: z.string().nullable(),+ activeProjectId: z.string().nullable().describe(SecretScanningProjects.GET_INSTANCE.activeProjectId),projects: z.object({- id: z.string(),- name: z.string(),- slug: z.string(),- createdAt: z.date()+ id: z.string().describe(SecretScanningProjects.GET_INSTANCE.id),+ name: z.string().describe(SecretScanningProjects.GET_INSTANCE.name),+ slug: z.string().describe(SecretScanningProjects.GET_INSTANCE.slug),+ createdAt: z.date().describe(SecretScanningProjects.GET_INSTANCE.createdAt)})- .array(),- isMultiInstance: z.boolean()+ .array()+ .describe(SecretScanningProjects.GET_INSTANCE.projects),+ isMultiInstance: z.boolean().describe(SecretScanningProjects.GET_INSTANCE.isMultiInstance)})}},diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex b523494c51..4b002f9ca5 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3939,6 +3939,23 @@ export const SecretScanningConfigs = {}};+export const SecretScanningProjects = {+ GET_ACTIVE: {+ projectId:+ "The ID of the organization's active Secret Scanning project, which is the most recently created one. One is created if the organization has none."+ },+ GET_INSTANCE: {+ activeProjectId:+ "The ID of the organization's active Secret Scanning project, which is the most recently created one. Null if the organization has none.",+ projects: "Every Secret Scanning project in the organization, most recently created first.",+ id: "The ID of the Secret Scanning project.",+ name: "The name of the Secret Scanning project.",+ slug: "The slug of the Secret Scanning project.",+ createdAt: "When the Secret Scanning project was created.",+ isMultiInstance: "Whether the organization has more than one Secret Scanning project."+ }+};+export const OidcSSo = {GET_CONFIG: {organizationId: "The ID of the organization to get the OIDC config for."diff --git a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/route.tsx b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/route.tsxindex 4c7ad53427..b7874d8066 100644--- a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/route.tsx+++ b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/route.tsx@@ -1,6 +1,7 @@import { createMongoAbility, MongoAbility, RawRuleOf } from "@casl/ability";import { unpackRules } from "@casl/ability/extra";import { createFileRoute, redirect } from "@tanstack/react-router";+import axios from "axios";import {OrgPermissionAdminConsoleAction,@@ -59,18 +60,24 @@ export const Route = createFileRoute(return;}- let isMember = true;+ const toProject = redirect({+ to: "/organizations/$orgId/projects/secret-scanning/$projectId/data-sources",+ params: { orgId: params.orgId, projectId }+ });+try {await context.queryClient.ensureQueryData({queryKey: roleQueryKeys.getUserProjectPermissions({ projectId }),- queryFn: () => fetchUserProjectPermissions({ projectId })+ queryFn: () => fetchUserProjectPermissions({ projectId }),+ retry: false});- } catch {- isMember = false;- }+ } catch (err) {+ // Only a missing membership leads to a join: grant-admin-access replaces an existing member's+ // roles with Admin, so any other failure must stay an error.+ const isNotAMember =+ axios.isAxiosError(err) && err.response?.data?.error === "ProjectMembershipNotFound";+ if (!isNotAMember) throw err;- if (!isMember) {- // The project is created with no members, so org admins join it here, as the home card does.const orgPermissions = await context.queryClient.ensureQueryData({queryKey: roleQueryKeys.getUserOrgPermissions({ orgId: params.orgId }),queryFn: () => fetchUserOrgPermissions({ orgId: params.orgId })@@ -79,30 +86,21 @@ export const Route = createFileRoute(unpackRules<RawRuleOf<MongoAbility<OrgPermissionSet>>>(orgPermissions.permissions),{ conditionsMatcher });+ const isOrgAdmin = orgAbility.can(+ OrgPermissionAdminConsoleAction.AccessAllProjects,+ OrgPermissionSubjects.AdminConsole+ );- if (- orgAbility.can(- OrgPermissionAdminConsoleAction.AccessAllProjects,- OrgPermissionSubjects.AdminConsole- )- ) {- try {- await grantOrgAdminProjectAccess({ projectId });- isMember = true;- } catch {- // Fall through to the list, where the admin can still join from All Projects.- }- }+ // Org admins promoted after the project was created are not seeded into it, so they join here, as+ // the home card does. Everyone else stays on the list to request access.+ if (isOrgAdmin) await grantOrgAdminProjectAccess({ projectId });// The cached project list predates this join or a project created just now.await context.queryClient.invalidateQueries({ queryKey: projectKeys.allProjectQueries() });- }- if (isMember) {- throw redirect({- to: "/organizations/$orgId/projects/secret-scanning/$projectId/data-sources",- params: { orgId: params.orgId, projectId }- });+ if (!isOrgAdmin) return;}++ throw toProject;}});