mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 04:26:33 +00:00
fix: correct host normalization logic in MongoDB connection functions
This commit is contained in:
+4
-4
@@ -55,9 +55,9 @@ export const mongodbCredentialsRotationFactory: TRotationFactory<
|
|||||||
|
|
||||||
const isSrvFromHost = srvRegex.test(normalizedHost);
|
const isSrvFromHost = srvRegex.test(normalizedHost);
|
||||||
if (isSrvFromHost) {
|
if (isSrvFromHost) {
|
||||||
normalizedHost = normalizedHost.replace(srvRegex, "");
|
normalizedHost = srvRegex.replace(normalizedHost, "");
|
||||||
} else if (protocolRegex.test(normalizedHost)) {
|
} else if (protocolRegex.test(normalizedHost)) {
|
||||||
normalizedHost = normalizedHost.replace(protocolRegex, "");
|
normalizedHost = protocolRegex.replace(normalizedHost, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
||||||
@@ -77,12 +77,12 @@ export const mongodbCredentialsRotationFactory: TRotationFactory<
|
|||||||
username: authCredentials.username,
|
username: authCredentials.username,
|
||||||
password: authCredentials.password
|
password: authCredentials.password
|
||||||
},
|
},
|
||||||
authSource: connection.credentials.database,
|
authSource: isSrv ? undefined : connection.credentials.database,
|
||||||
directConnection: !isSrv
|
directConnection: !isSrv
|
||||||
};
|
};
|
||||||
|
|
||||||
// SSL is enabled if explicitly enabled OR if using SRV (which requires TLS) and requireTlsForSrv is true
|
// SSL is enabled if explicitly enabled OR if using SRV (which requires TLS) and requireTlsForSrv is true
|
||||||
if (connection.credentials.sslEnabled || (isSrv && options?.requireTlsForSrv)) {
|
if (connection.credentials.sslEnabled) {
|
||||||
clientOptions.tls = true;
|
clientOptions.tls = true;
|
||||||
clientOptions.tlsInsecure = !connection.credentials.sslRejectUnauthorized;
|
clientOptions.tlsInsecure = !connection.credentials.sslRejectUnauthorized;
|
||||||
if (connection.credentials.sslCertificate) {
|
if (connection.credentials.sslCertificate) {
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ export const validateMongoDBConnectionCredentials = async (config: TMongoDBConne
|
|||||||
let normalizedHost = config.credentials.host.trim();
|
let normalizedHost = config.credentials.host.trim();
|
||||||
const isSrvFromHost = srvRegex.test(normalizedHost);
|
const isSrvFromHost = srvRegex.test(normalizedHost);
|
||||||
if (isSrvFromHost) {
|
if (isSrvFromHost) {
|
||||||
normalizedHost = normalizedHost.replace(srvRegex, "");
|
normalizedHost = srvRegex.replace(normalizedHost, "");
|
||||||
} else if (protocolRegex.test(normalizedHost)) {
|
} else if (protocolRegex.test(normalizedHost)) {
|
||||||
normalizedHost = normalizedHost.replace(protocolRegex, "");
|
normalizedHost = protocolRegex.replace(normalizedHost, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
||||||
@@ -48,7 +48,7 @@ export const validateMongoDBConnectionCredentials = async (config: TMongoDBConne
|
|||||||
username: config.credentials.username,
|
username: config.credentials.username,
|
||||||
password: config.credentials.password
|
password: config.credentials.password
|
||||||
},
|
},
|
||||||
authSource: config.credentials.database,
|
authSource: isSrv ? undefined : config.credentials.database,
|
||||||
directConnection: !isSrv
|
directConnection: !isSrv
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user