mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: correct host normalization logic in MongoDB connection functions
This commit is contained in:
@@ -55,9 +55,9 @@ export const mongodbCredentialsRotationFactory: TRotationFactory<
|
||||
|
||||
const isSrvFromHost = srvRegex.test(normalizedHost);
|
||||
if (isSrvFromHost) {
|
||||
normalizedHost = normalizedHost.replace(srvRegex, "");
|
||||
normalizedHost = srvRegex.replace(normalizedHost, "");
|
||||
} else if (protocolRegex.test(normalizedHost)) {
|
||||
normalizedHost = normalizedHost.replace(protocolRegex, "");
|
||||
normalizedHost = protocolRegex.replace(normalizedHost, "");
|
||||
}
|
||||
|
||||
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
||||
@@ -77,12 +77,12 @@ export const mongodbCredentialsRotationFactory: TRotationFactory<
|
||||
username: authCredentials.username,
|
||||
password: authCredentials.password
|
||||
},
|
||||
authSource: connection.credentials.database,
|
||||
authSource: isSrv ? undefined : connection.credentials.database,
|
||||
directConnection: !isSrv
|
||||
};
|
||||
|
||||
// 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.tlsInsecure = !connection.credentials.sslRejectUnauthorized;
|
||||
if (connection.credentials.sslCertificate) {
|
||||
|
||||
@@ -24,9 +24,9 @@ export const validateMongoDBConnectionCredentials = async (config: TMongoDBConne
|
||||
let normalizedHost = config.credentials.host.trim();
|
||||
const isSrvFromHost = srvRegex.test(normalizedHost);
|
||||
if (isSrvFromHost) {
|
||||
normalizedHost = normalizedHost.replace(srvRegex, "");
|
||||
normalizedHost = srvRegex.replace(normalizedHost, "");
|
||||
} else if (protocolRegex.test(normalizedHost)) {
|
||||
normalizedHost = normalizedHost.replace(protocolRegex, "");
|
||||
normalizedHost = protocolRegex.replace(normalizedHost, "");
|
||||
}
|
||||
|
||||
const [hostIp] = await verifyHostInputValidity(normalizedHost);
|
||||
@@ -48,7 +48,7 @@ export const validateMongoDBConnectionCredentials = async (config: TMongoDBConne
|
||||
username: config.credentials.username,
|
||||
password: config.credentials.password
|
||||
},
|
||||
authSource: config.credentials.database,
|
||||
authSource: isSrv ? undefined : config.credentials.database,
|
||||
directConnection: !isSrv
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user