Skip to content

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

pam: return metadata for pam access requests

x032205fc395bf66100
diff --git a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
index d2e0183ffb..286e0896fa 100644
--- a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
@@ -92,7 +92,8 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
gatewayClientCertificate: z.string(),
gatewayClientPrivateKey: z.string(),
gatewayServerCertificateChain: z.string(),
- relayHost: z.string()
+ relayHost: z.string(),
+ metadata: z.record(z.string(), z.string()).optional()
})
}
},
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 00b84943f0..0316ecebfd 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -480,6 +480,30 @@ export const pamAccountServiceFactory = ({
throw new NotFoundError({ message: `Gateway connection details for gateway '${gatewayId}' not found.` });
}
+ let metadata;
+
+ switch (resourceType) {
+ case PamResource.Postgres:
+ case PamResource.MySQL: {
+ const connectionCredentials = await decryptResourceConnectionDetails({
+ encryptedConnectionDetails: resource.encryptedConnectionDetails,
+ kmsService,
+ projectId: account.projectId
+ });
+
+ const credentials = await decryptAccountCredentials({
+ encryptedCredentials: account.encryptedCredentials,
+ kmsService,
+ projectId: account.projectId
+ });
+
+ metadata = {
+ username: credentials.username,
+ database: connectionCredentials.database
+ };
+ }
+ }
+
return {
sessionId: session.id,
resourceType,
@@ -491,7 +515,8 @@ export const pamAccountServiceFactory = ({
gatewayServerCertificateChain: gatewayConnectionDetails.gateway.serverCertificateChain,
relayHost: gatewayConnectionDetails.relayHost,
projectId: account.projectId,
- account
+ account,
+ metadata
};
};