提交 89ec8b39 编写于 作者: R rsercano

resolves #346

上级 c5e30fe2
......@@ -55,8 +55,8 @@ export const parseUrl = function (connection) {
connection[connection.authenticationType].username = parsedUrl.auth.user ? parsedUrl.auth.user : '';
connection[connection.authenticationType].password = parsedUrl.auth.password ? parsedUrl.auth.password : '';
}
if (parsedUrl.db_options.authSource && (connection.authenticationType === 'mongodb_cr' || connection.authenticationType === 'scram_sha_1')) {
connection[connection.authenticationType].authSource = parsedUrl.db_options.authSource;
if (connection.authenticationType === 'mongodb_cr' || connection.authenticationType === 'scram_sha_1') {
connection[connection.authenticationType].authSource = parsedUrl.db_options.authSource ? parsedUrl.db_options.authSource : connection.databaseName;
}
return connection;
......@@ -130,9 +130,10 @@ Meteor.methods({
try {
const response = HTTP.get('https://api.github.com/repos/mongoclient/mongoclient/releases/latest', {headers: {"User-Agent": "Mongoclient"}});
if (response && response.data && response.data.name && response.data.name !== packageJson.version) {
return "There's a new version of mongoclient: " + response.data.name + ", <a href='https://github.com/mongoclient/mongoclient/releases/latest' target='_blank'>download here</a>, if you're using docker just use pull !";
return "There's a new version of mongoclient: " + response.data.name + ", <a href='https://github.com/mongoclient/mongoclient/releases/latest' target='_blank'>download here</a>, if you're using docker just use pull for the <b>" + response.data.name + "</b> or <b>latest</b> tag !";
}
} catch (e) {
LOGGER.error('[checkMongoclientVersion]', e);
return null;
}
},
......
......@@ -2,7 +2,7 @@
* Created by RSercan on 30.12.2015.
*/
import {Settings} from "/lib/imports/collections/settings";
import {serialize, deserialize} from "./extended_json";
import {deserialize, serialize} from "./extended_json";
const addOptionToUrl = function (url, option, value) {
if (!value) return '';
......@@ -70,12 +70,8 @@ Helper.prototype = {
// options
if (connection.authenticationType) connectionUrl += addOptionToUrl(connectionUrl, 'authMechanism', connection.authenticationType.toUpperCase().replace(new RegExp("_", 'g'), "-"));
if (connection.authenticationType === 'mongodb_cr' || connection.authenticationType === 'scram_sha_1') connectionUrl += addOptionToUrl(connectionUrl, 'authSource', connection[connection.authenticationType].authSource);
else if (connection.authenticationType === 'mongodb_x509') connectionUrl += addOptionToUrl(connectionUrl, 'ssl', 'true');
else if (connection.authenticationType === 'gssapi' || connection.authenticationType === 'plain') {
if (connection.authenticationType === 'gssapi') connectionUrl += addOptionToUrl(connectionUrl, 'gssapiServiceName', connection.gssapi.serviceName);
connectionUrl += addOptionToUrl(connectionUrl, 'authSource', '$external');
}
if (connection.authenticationType === 'mongodb_x509') connectionUrl += addOptionToUrl(connectionUrl, 'ssl', 'true');
else if (connection.authenticationType === 'gssapi') connectionUrl += addOptionToUrl(connectionUrl, 'gssapiServiceName', connection.gssapi.serviceName);
if (connection.options) {
if (connection.options.readPreference) connectionUrl += addOptionToUrl(connectionUrl, 'readPreference', connection.options.readPreference);
......@@ -100,6 +96,14 @@ Helper.prototype = {
if (connection.ssl && connection.ssl.enabled) addSSLOptions(connection.ssl, result);
if (connection.options && connection.options.connectWithNoPrimary) result.connectWithNoPrimary = true;
// added authSource to here to provide same authSource as DB name if it's not provided when connection is being used by URL
if (connection.authenticationType === 'mongodb_cr' || connection.authenticationType === 'scram_sha_1') {
if (connection[connection.authenticationType].authSource) result.authSource = connection[connection.authenticationType].authSource;
else result.authSource = connection.databaseName;
}
else if (connection.authenticationType === 'gssapi' || connection.authenticationType === 'plain') {
result.authSource = '$external';
}
return result;
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册