Fix multiple DB login issues

This commit is contained in:
Raúl Marín 2019-11-12 13:12:01 +01:00
parent 3c586caba4
commit aa09c079f6
5 changed files with 12 additions and 17 deletions

View File

@ -15,6 +15,7 @@ Announcements:
- When `cache buster` in request path is `0` set header `Last-Modified` to now, it avoids stalled content in 3rd party cache providers when they add `If-Modified-Since` header into the request. - When `cache buster` in request path is `0` set header `Last-Modified` to now, it avoids stalled content in 3rd party cache providers when they add `If-Modified-Since` header into the request.
- Adding a logger to MapStore (#1134) - Adding a logger to MapStore (#1134)
- Qualify calls to cartodb extension so having it in the search_path isn't necessary. - Qualify calls to cartodb extension so having it in the search_path isn't necessary.
- Fix multiple DB login issues.
## 7.2.0 ## 7.2.0
Released 2019-09-30 Released 2019-09-30

View File

@ -3,6 +3,7 @@
var PSQL = require('cartodb-psql'); var PSQL = require('cartodb-psql');
var _ = require('underscore'); var _ = require('underscore');
const debug = require('debug')('cachechan'); const debug = require('debug')('cachechan');
const dbParamsFromReqParams = require('../utils/database-params');
function PgConnection(metadataBackend) { function PgConnection(metadataBackend) {
this.metadataBackend = metadataBackend; this.metadataBackend = metadataBackend;
@ -124,14 +125,7 @@ PgConnection.prototype.getConnection = function(username, callback) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
return callback(err, new PSQL({ return callback(err, new PSQL(dbParamsFromReqParams(databaseParams)));
user: databaseParams.dbuser,
pass: databaseParams.dbpass,
host: databaseParams.dbhost,
port: databaseParams.dbport,
dbname: databaseParams.dbname
}));
}); });
}; };

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var PSQL = require('cartodb-psql'); var PSQL = require('cartodb-psql');
const dbParamsFromReqParams = require('../utils/database-params');
function PgQueryRunner(pgConnection) { function PgQueryRunner(pgConnection) {
this.pgConnection = pgConnection; this.pgConnection = pgConnection;
@ -22,13 +23,7 @@ PgQueryRunner.prototype.run = function(username, query, callback) {
return callback(err); return callback(err);
} }
const psql = new PSQL({ const psql = new PSQL(dbParamsFromReqParams(databaseParams));
user: databaseParams.dbuser,
pass: databaseParams.dbpass,
host: databaseParams.dbhost,
port: databaseParams.dbport,
dbname: databaseParams.dbname
});
psql.query(query, function (err, resultSet) { psql.query(query, function (err, resultSet) {
resultSet = resultSet || {}; resultSet = resultSet || {};

View File

@ -92,7 +92,12 @@ MapConfigNamedLayersAdapter.prototype.getMapConfig = function (user, requestMapC
layers.push(layer); layers.push(layer);
if (layersResult.datasource) { if (layersResult.datasource) {
datasourceBuilder.withLayerDatasource(currentLayerIndex, { datasourceBuilder.withLayerDatasource(currentLayerIndex, {
user: dbAuth.dbuser user: dbAuth.dbuser,
// Used internally (PSQL)
pass: dbAuth.dbpassword,
dbpassword: dbAuth.dbpassword,
// Used by Mapnik
password: dbAuth.dbpassword
}); });
} }
currentLayerIndex++; currentLayerIndex++;

View File

@ -242,7 +242,7 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
} }
dbParams.dbuser = databaseParams.dbuser; dbParams.dbuser = databaseParams.dbuser;
dbParams.dbpass = databaseParams.dbpass; dbParams.dbpassword = databaseParams.dbpassword;
dbParams.dbhost = databaseParams.dbhost; dbParams.dbhost = databaseParams.dbhost;
dbParams.dbport = databaseParams.dbport; dbParams.dbport = databaseParams.dbport;
dbParams.dbname = databaseParams.dbname; dbParams.dbname = databaseParams.dbname;