Implements authDbParams interface
Uses user and pass from redis and relies on rest of params prepared for normal dbParams
This commit is contained in:
parent
e70a21a2b4
commit
86ecc3ad0a
@ -31,14 +31,7 @@ UserDatabaseService.prototype.getConnectionParams = function (authApi, cdbUserna
|
||||
// 3. Set to user authorization params
|
||||
step(
|
||||
function getDatabaseConnectionParams() {
|
||||
var next = this;
|
||||
|
||||
// If the request is providing credentials it may require every DB parameters
|
||||
if (authApi.hasCredentials()) {
|
||||
self.metadataBackend.getAllUserDBParams(cdbUsername, next);
|
||||
} else {
|
||||
self.metadataBackend.getUserDBPublicConnectionParams(cdbUsername, next);
|
||||
}
|
||||
self.metadataBackend.getAllUserDBParams(cdbUsername, this);
|
||||
},
|
||||
function authenticate(err, userDBParams) {
|
||||
var next = this;
|
||||
@ -66,27 +59,31 @@ UserDatabaseService.prototype.getConnectionParams = function (authApi, cdbUserna
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (_.isBoolean(isAuthenticated) && isAuthenticated) {
|
||||
dbopts.authenticated = isAuthenticated;
|
||||
dbopts.user = _.template(global.settings.db_user, {user_id: dbParams.dbuser});
|
||||
if ( global.settings.hasOwnProperty('db_user_pass') ) {
|
||||
dbopts.pass = _.template(global.settings.db_user_pass, {
|
||||
user_id: dbParams.dbuser,
|
||||
user_password: dbParams.dbpass
|
||||
});
|
||||
} else {
|
||||
delete dbopts.pass;
|
||||
}
|
||||
var user = _.template(global.settings.db_user, {user_id: dbParams.dbuser});
|
||||
var pass = null;
|
||||
if (global.settings.hasOwnProperty('db_user_pass')) {
|
||||
pass = _.template(global.settings.db_user_pass, {
|
||||
user_id: dbParams.dbuser,
|
||||
user_password: dbParams.dbpass
|
||||
});
|
||||
}
|
||||
|
||||
return dbopts;
|
||||
if (_.isBoolean(isAuthenticated) && isAuthenticated) {
|
||||
dbopts.authenticated = isAuthenticated;
|
||||
dbopts.user = user;
|
||||
dbopts.pass = pass;
|
||||
}
|
||||
|
||||
var authDbOpts = _.defaults({user: user, pass: pass}, dbopts);
|
||||
|
||||
return this(null, dbopts, authDbOpts);
|
||||
},
|
||||
function errorHandle(err, dbopts) {
|
||||
function errorHandle(err, dbopts, authDbOpts) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, dbopts, dbopts);
|
||||
callback(null, dbopts, authDbOpts);
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user