Skip to content

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

review fixes

x933991560bca
diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
index d05eb7b751..23c999a71f 100644
--- a/backend/src/ee/services/pam-account/pam-account-connection-test.ts
+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
@@ -1,3 +1,5 @@
+import ConnectionString from "mongodb-connection-string-url";
+
import { PamAccountType, PamSshAuthMethod } from "../pam/pam-enums";
import {
AWS_STS_MIN_DURATION_SECONDS,
@@ -32,7 +34,7 @@ export type TestConnectionRequest =
mode: TestConnectionMode.MongoDB;
username: string;
password?: string;
- database: string;
+ authSource: string;
sslEnabled?: boolean;
sslRejectUnauthorized?: boolean;
sslCertificate?: string;
@@ -105,6 +107,7 @@ export const buildGatewayConnectionTest = async (
}
case PamAccountType.MongoDB: {
const cd = connectionDetails as {
+ connectionString: string;
database: string;
sslEnabled?: boolean;
sslRejectUnauthorized?: boolean;
@@ -112,6 +115,7 @@ export const buildGatewayConnectionTest = async (
};
const c = creds as { username: string; password?: string } | null;
if (!c) return tcp(host, port);
+ const authSource = new ConnectionString(cd.connectionString).searchParams.get("authSource") || cd.database;
return {
host,
port,
@@ -119,7 +123,7 @@ export const buildGatewayConnectionTest = async (
mode: TestConnectionMode.MongoDB,
username: c.username,
password: c.password,
- database: cd.database,
+ authSource,
sslEnabled: cd.sslEnabled,
sslRejectUnauthorized: cd.sslRejectUnauthorized,
sslCertificate: cd.sslCertificate
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index 9da9260cb3..1eaaabd80d 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -665,7 +665,8 @@ export const extractGatewayTarget = async (
case PamAccountType.Kubernetes: {
const { url } = validated as { url: string };
const parsed = new URL(url);
- return { host: parsed.hostname, port: parsed.port ? Number(parsed.port) : 443 };
+ const defaultPort = parsed.protocol === "http:" ? 80 : 443;
+ return { host: parsed.hostname, port: parsed.port ? Number(parsed.port) : defaultPort };
}
case PamAccountType.MongoDB: {
const { connectionString } = validated as { connectionString: string };
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 44e74a0eaf..09d0960689 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -644,7 +644,10 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
: validateConnectionDetails(accountType, await decrypt(projectId, existing.encryptedConnectionDetails));
// only test with credentials supplied in this request to prevent exfiltration
- const testCredentials = credentials ? validateCredentials(accountType, credentials) : null;
+ let testCredentials = credentials ? validateCredentials(accountType, credentials) : null;
+ if (!testCredentials && CLOUD_CONNECTION_VALIDATORS[accountType]) {
+ testCredentials = validateCredentials(accountType, await decrypt(projectId, existing.encryptedCredentials));
+ }
await assertConnectionOk(
accountType,
effectiveConnectionDetails,