change var SAML definition
This commit is contained in:
parent
92365d7d7f
commit
505ed26789
1 changed files with 185 additions and 183 deletions
36
library.js
36
library.js
|
|
@ -21,10 +21,11 @@
|
|||
});
|
||||
|
||||
var master_config = {};
|
||||
var SAML = {};
|
||||
var samlObj;
|
||||
|
||||
SAML.init = function(params, callback) {
|
||||
var SAML = {
|
||||
|
||||
init: function(params, callback) {
|
||||
|
||||
function render(req, res, next) {
|
||||
res.render('admin/plugins/sso-saml', {});
|
||||
|
|
@ -40,9 +41,9 @@
|
|||
|
||||
console.log("[sso-saml] init done");
|
||||
callback();
|
||||
};
|
||||
},
|
||||
|
||||
SAML.get_config = function(options, callback) {
|
||||
get_config: function(options, callback) {
|
||||
meta.settings.get('sso_saml', function(err, settings) {
|
||||
if (err) {
|
||||
return callback(null, options);
|
||||
|
|
@ -51,9 +52,9 @@
|
|||
options.sso_saml = settings;
|
||||
callback(null, options);
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
SAML.initSaml = function() {
|
||||
initSaml: function() {
|
||||
if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
||||
console.log("creating samlObj");
|
||||
samlObj = new passportSAML({
|
||||
|
|
@ -147,11 +148,11 @@
|
|||
else {
|
||||
console.log("[sso-saml] Cannot create samlObj");
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
SAML.getStrategy = function(strategies, callback) {
|
||||
getStrategy: function(strategies, callback) {
|
||||
|
||||
SAML.initSaml();
|
||||
this.initSaml();
|
||||
|
||||
if (samlObj){
|
||||
|
||||
|
|
@ -167,9 +168,9 @@
|
|||
}
|
||||
|
||||
callback(null, strategies);
|
||||
};
|
||||
},
|
||||
|
||||
SAML.login = function(userdata, callback) {
|
||||
login: function(userdata, callback) {
|
||||
|
||||
SAML.getUidBySAMLId(userdata.username, function(err, uid) {
|
||||
if(err) {
|
||||
|
|
@ -203,18 +204,18 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
SAML.getUidBySAMLId = function(samlid, callback) {
|
||||
getUidBySAMLId: function(samlid, callback) {
|
||||
db.getObjectField('samlid:uid', samlid, function(err, uid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, uid);
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
SAML.addMenuItem = function(custom_header, callback) {
|
||||
addMenuItem: function(custom_header, callback) {
|
||||
custom_header.authentication.push({
|
||||
"route": constants.admin.route,
|
||||
"icon": constants.admin.icon,
|
||||
|
|
@ -222,9 +223,9 @@
|
|||
});
|
||||
|
||||
callback(null, custom_header);
|
||||
};
|
||||
},
|
||||
|
||||
SAML.deleteUserData = function(uid, callback) {
|
||||
deleteUserData: function(uid, callback) {
|
||||
async.waterfall([
|
||||
async.apply(user.getUserField, uid, 'samlid'),
|
||||
function(idToDelete, next) {
|
||||
|
|
@ -237,6 +238,7 @@
|
|||
}
|
||||
callback(null, uid);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = SAML;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue