Skip to content

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

chore(pam): hide internal project endpoint from docs and trim verbose comments

bernie-g3b25ce409796
diff --git a/backend/src/db/migrations/20260612142201_pam-revamp.ts b/backend/src/db/migrations/20260612142201_pam-revamp.ts
index bc29692b62..2f9de78e4c 100644
--- a/backend/src/db/migrations/20260612142201_pam-revamp.ts
+++ b/backend/src/db/migrations/20260612142201_pam-revamp.ts
@@ -102,9 +102,8 @@ const mapToFolderAdminRoleRows = (activeRoles: TRoleRow[]) => {
return [...mapped.values()];
};
-// Only orgs that already have PAM data get a consolidated project during the migration. Orgs with
-// no PAM data get one lazily on first PAM access (see pamProjectResolver), avoiding tens of
-// thousands of empty projects here. Chunked inserts keep even the migrated set fast.
+// Only orgs with existing PAM data get a project here; the rest are created lazily on first access
+// (see pamProjectResolver) to avoid backfilling tens of thousands of empty projects.
const backfillPamProjectsForOrgs = async (knex: Knex, orgIds: string[]) => {
const orgToPamProject = new Map<string, string>();
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-project-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-project-router.ts
index c6f41636b1..2457ea5deb 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-project-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-project-router.ts
@@ -10,6 +10,8 @@ export const registerPamProjectRouter = async (server: FastifyZodProvider) => {
method: "GET",
url: "/",
schema: {
+ // Internal endpoint; PAM projects are never user-facing, so keep it out of the API docs
+ hide: true,
operationId: "getPamProject",
description: "Resolve the organization's Privileged Access Manager project, creating it on first access",
tags: [ApiDocsTags.PamFolders],
@@ -21,8 +23,7 @@ export const registerPamProjectRouter = async (server: FastifyZodProvider) => {
},
config: { rateLimit: readLimit },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
- // injectPamProjectId (preValidation) resolves and lazily bootstraps the project, so by the time
- // this handler runs internalPamProjectId is always set.
+ // injectPamProjectId (preValidation) has already resolved/bootstrapped the project by now.
handler: async (req) => ({ projectId: req.internalPamProjectId })
});
};
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 491c5c8aaf..bab7a630bc 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -608,9 +608,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
ResourcePermissionSub.PamResource
);
- // The membership roster is only for member management, so don't disclose it to read-only callers
- // (e.g. Connector/Requester have ReadAccounts but not ManageMembers) — that would leak the full
- // list of users/groups/identities and their roles on the account and parent folder.
+ // Only member managers get the roster; read-only roles must not enumerate members.
const canManageMembers = mergedPermission.can(
ResourcePermissionPamResourceActions.ManageMembers,
ResourcePermissionSub.PamResource
diff --git a/backend/src/ee/services/pam-folder/pam-folder-service.ts b/backend/src/ee/services/pam-folder/pam-folder-service.ts
index 695347c37c..9e921a427e 100644
--- a/backend/src/ee/services/pam-folder/pam-folder-service.ts
+++ b/backend/src/ee/services/pam-folder/pam-folder-service.ts
@@ -212,9 +212,7 @@ export const pamFolderServiceFactory = ({
ResourcePermissionSub.PamResource
);
- // The membership roster is only for member management, so don't disclose it to read-only callers
- // (e.g. Connector/Requester have ReadFolder but not ManageMembers) — that would leak the full list
- // of users/groups/identities and their roles on the folder.
+ // Only member managers get the roster; read-only roles must not enumerate members.
const canManageMembers = permission.can(
ResourcePermissionPamResourceActions.ManageMembers,
ResourcePermissionSub.PamResource
diff --git a/backend/src/ee/services/pam-project/pam-project-resolver.ts b/backend/src/ee/services/pam-project/pam-project-resolver.ts
index b01e2bdad9..32ec769003 100644
--- a/backend/src/ee/services/pam-project/pam-project-resolver.ts
+++ b/backend/src/ee/services/pam-project/pam-project-resolver.ts
@@ -32,8 +32,7 @@ export const pamProjectResolverFactory = ({
membershipRoleDAL,
keyStore
}: TResolverDeps) => {
- // projectDAL.find already excludes soft-deleted (deleteAfter) projects. Passing tx runs the read
- // on the primary inside the caller's transaction (used for the in-lock re-check).
+ // Newest live PAM project (find() excludes soft-deleted); tx reads the primary for the in-lock re-check.
const findDefaultProjectId = async (orgId: string, tx?: Knex): Promise<string | null> => {
const projects = await projectDAL.find(
{ orgId, type: ProjectType.PAM },
@@ -42,19 +41,13 @@ export const pamProjectResolverFactory = ({
return projects.length ? projects[0].id : null;
};
- // Orgs with no PAM data get no consolidated project during the migration; the first PAM request
- // creates it here, seeded with the org's current admins so it is immediately usable (otherwise
- // no one could administer it, since the PAM permission model has no org-admin fallback).
+ // Lazily create the project on first use, seeded with current org admins (PAM has no org-admin fallback).
const ensureDefaultProject = (orgId: string): Promise<string> =>
db.transaction(async (tx) => {
- // Serialize concurrent first-use bootstraps for the same org. There is no DB unique
- // constraint to rely on (old zombie PAM projects also have type=pam, so an org can legitimately
- // have several), and the advisory lock auto-releases when this transaction ends.
+ // Serialize concurrent bootstraps; a unique constraint won't work since zombie projects share type=pam.
await tx.raw("SELECT pg_advisory_xact_lock(hashtext(?))", [`pam-bootstrap:${orgId}`]);
- // Re-check inside the lock on the primary (tx). Resolves the race winner and, when several PAM
- // projects exist (consolidated + old zombies), returns the consolidated one rather than a
- // stale/arbitrary row.
+ // Re-check inside the lock (race winner).
const existingId = await findDefaultProjectId(orgId, tx);
if (existingId) return existingId;
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 08e7b6c8cb..f79e5c0b85 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -259,10 +259,8 @@ export const pamSessionServiceFactory = ({
sessionId
};
} else {
- // Re-fetch (e.g. gateway restart/resume or a transient retry): the recording secrets are only
- // issued once, so return the existing session key by decrypting the stored one. The upload
- // token is left empty on purpose — the server only keeps its hash, and the gateway supplies its
- // own disk-persisted token. Without this, a session spanning a gateway restart loses recording.
+ // On re-fetch (e.g. gateway restart) return the existing key; empty token since the gateway
+ // restores its own from disk and the server only keeps the token hash.
const sessionKey = await decryptSessionKey({
projectId: session.projectId,
sessionId,
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts
index b9b8838aed..5d8ed9314c 100644
--- a/backend/src/services/project/project-service.ts
+++ b/backend/src/services/project/project-service.ts
@@ -791,9 +791,7 @@ export const projectServiceFactory = ({
});
}
- // PAM projects are not deletable here: the consolidated project is managed (one active project
- // per org, recreated on demand), and any leftover pre-migration PAM projects still hold FK
- // references from migrated accounts, so cascade-deleting them would break/erase that data.
+ // PAM projects are managed (one per org); deleting would also cascade FK-referenced migrated data.
if (project.type === ProjectType.PAM) {
throw new BadRequestError({
message: "Privileged Access Manager projects cannot be deleted."
diff --git a/frontend/src/pages/pam/layout.tsx b/frontend/src/pages/pam/layout.tsx
index cbbba36d62..e700caef4c 100644
--- a/frontend/src/pages/pam/layout.tsx
+++ b/frontend/src/pages/pam/layout.tsx
@@ -21,11 +21,8 @@ export const Route = createFileRoute(
let pamProjectId = org?.pamProjectId;
if (!pamProjectId) {
- // The org has no consolidated PAM project yet (lazy creation). Hitting the PAM endpoint
- // bootstraps it server-side and returns its id. Patch it straight into the cached org so the
- // contexts that read it (ProjectContext / ProjectPermissionContext) pick it up. We inject the
- // id we just got rather than refetching the org, which avoids a round-trip and the read-replica
- // lag window where getOrgById could still re-derive pamProjectId=null right after the write.
+ // Lazily bootstrap the project and patch its id into the cached org so the Project/ProjectPermission
+ // contexts pick it up (injecting the returned id avoids a refetch that could race read-replica lag).
const resolvedPamProjectId = await fetchPamProjectId();
pamProjectId = resolvedPamProjectId;
context.queryClient.setQueryData<Organization>(