Skip to content

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

chore(pam-windows): restore recording-config check and metadata case

bernie-g6fd2f4b7a63a
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 67b629bdd5..72799850d6 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -65,6 +65,7 @@ import { TPamAccountDependenciesDALFactory } from "../pam-discovery/pam-account-
import { TPamDomainDALFactory } from "../pam-domain/pam-domain-dal";
import { PamDomainType } from "../pam-domain/pam-domain-enums";
import { PAM_DOMAIN_FACTORY_MAP } from "../pam-domain/pam-domain-factory";
+import { TPamProjectRecordingConfigDALFactory } from "../pam-project-recording-config/pam-project-recording-config-dal";
import { TPamProjectRecordingConfigServiceFactory } from "../pam-project-recording-config/pam-project-recording-config-service";
import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";
import { PamResource } from "../pam-resource/pam-resource-enums";
@@ -73,6 +74,7 @@ import { TPamAccountCredentials } from "../pam-resource/pam-resource-types";
import { TRedisAccountCredentials } from "../pam-resource/redis/redis-resource-types";
import { TSqlAccountCredentials, TSqlResourceConnectionDetails } from "../pam-resource/shared/sql/sql-resource-types";
import { TSSHAccountCredentials, TSSHResourceInternalMetadata } from "../pam-resource/ssh/ssh-resource-types";
+import { TWindowsAccountCredentials } from "../pam-resource/windows-server/windows-server-resource-types";
import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";
import { PamSessionStatus } from "../pam-session/pam-session-enums";
import { decryptSessionKey, generateSessionRecordingSecrets } from "../pam-session/pam-session-recording-secrets";
@@ -125,6 +127,7 @@ type TPamAccountServiceFactoryDep = {
"findByAccountId" | "updateById" | "countByAccountIds"
>;
keyStore: Pick<TKeyStoreFactory, "setItemWithExpiry" | "getItem">;
+ pamProjectRecordingConfigDAL: Pick<TPamProjectRecordingConfigDALFactory, "findByProjectId">;
pamProjectRecordingConfigService: Pick<TPamProjectRecordingConfigServiceFactory, "resolveConfigForProject">;
};
@@ -153,6 +156,7 @@ export const pamAccountServiceFactory = ({
resourceMetadataDAL,
pamAccountDependenciesDAL,
keyStore,
+ pamProjectRecordingConfigDAL,
pamProjectRecordingConfigService
}: TPamAccountServiceFactoryDep) => {
// Helper to resolve account parent (resource or domain)
@@ -892,11 +896,24 @@ export const pamAccountServiceFactory = ({
kmsService
);
- // Temporarily disable access to Windows Server
- if (resourceType === PamResource.Windows) {
+ // Temporarily disable access to Windows Server. Cast prevents TS
+ // from narrowing resourceType to "not Windows" so the blocks below
+ // (recording-config check, metadata switch case) stay valid for
+ // when this disable is lifted.
+ if ((resourceType as PamResource) === PamResource.Windows) {
throw new BadRequestError({ message: `Windows resources cannot be accessed at this time` });
}
+ if (resourceType === PamResource.Windows) {
+ const recordingConfig = await pamProjectRecordingConfigDAL.findByProjectId(account.projectId);
+ if (!recordingConfig) {
+ throw new BadRequestError({
+ message:
+ "Windows resources require an external session recording configuration. Configure session recording in project settings before accessing Windows accounts."
+ });
+ }
+ }
+
const user = await userDAL.findById(actor.id);
if (!user) throw new NotFoundError({ message: `User with ID '${actor.id}' not found` });
@@ -1080,6 +1097,19 @@ export const pamAccountServiceFactory = ({
};
}
break;
+ case PamResource.Windows:
+ {
+ const credentials = (await decryptAccountCredentials({
+ encryptedCredentials: account.encryptedCredentials,
+ kmsService,
+ projectId
+ })) as TWindowsAccountCredentials;
+
+ metadata = {
+ username: credentials.username
+ };
+ }
+ break;
case PamResource.Kubernetes:
metadata = {
resourceName: resource.name,
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index b92bbf2b7f..5eefc5f9a1 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2997,6 +2997,7 @@ export const registerRoutes = async (
resourceMetadataDAL,
pamAccountDependenciesDAL,
keyStore,
+ pamProjectRecordingConfigDAL,
pamProjectRecordingConfigService
});