use proper class
This commit is contained in:
parent
505ed26789
commit
5bf2e8e007
1 changed files with 17 additions and 16 deletions
33
library.js
33
library.js
|
|
@ -23,9 +23,9 @@
|
|||
var master_config = {};
|
||||
var samlObj;
|
||||
|
||||
var SAML = {
|
||||
Class SsoSaml {
|
||||
|
||||
init: function(params, callback) {
|
||||
init(params, callback) {
|
||||
|
||||
function render(req, res, next) {
|
||||
res.render('admin/plugins/sso-saml', {});
|
||||
|
|
@ -41,9 +41,9 @@
|
|||
|
||||
console.log("[sso-saml] init done");
|
||||
callback();
|
||||
},
|
||||
}
|
||||
|
||||
get_config: function(options, callback) {
|
||||
get_config(options, callback) {
|
||||
meta.settings.get('sso_saml', function(err, settings) {
|
||||
if (err) {
|
||||
return callback(null, options);
|
||||
|
|
@ -52,9 +52,9 @@
|
|||
options.sso_saml = settings;
|
||||
callback(null, options);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
initSaml: function() {
|
||||
initSaml {
|
||||
if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
||||
console.log("creating samlObj");
|
||||
samlObj = new passportSAML({
|
||||
|
|
@ -148,9 +148,9 @@
|
|||
else {
|
||||
console.log("[sso-saml] Cannot create samlObj");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getStrategy: function(strategies, callback) {
|
||||
getStrategy(strategies, callback) {
|
||||
|
||||
this.initSaml();
|
||||
|
||||
|
|
@ -168,9 +168,9 @@
|
|||
}
|
||||
|
||||
callback(null, strategies);
|
||||
},
|
||||
}
|
||||
|
||||
login: function(userdata, callback) {
|
||||
login(userdata, callback) {
|
||||
|
||||
SAML.getUidBySAMLId(userdata.username, function(err, uid) {
|
||||
if(err) {
|
||||
|
|
@ -204,18 +204,18 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getUidBySAMLId: function(samlid, callback) {
|
||||
getUidBySAMLId(samlid, callback) {
|
||||
db.getObjectField('samlid:uid', samlid, function(err, uid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, uid);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
addMenuItem: function(custom_header, callback) {
|
||||
addMenuItem(custom_header, callback) {
|
||||
custom_header.authentication.push({
|
||||
"route": constants.admin.route,
|
||||
"icon": constants.admin.icon,
|
||||
|
|
@ -223,9 +223,9 @@
|
|||
});
|
||||
|
||||
callback(null, custom_header);
|
||||
},
|
||||
}
|
||||
|
||||
deleteUserData: function(uid, callback) {
|
||||
deleteUserData(uid, callback) {
|
||||
async.waterfall([
|
||||
async.apply(user.getUserField, uid, 'samlid'),
|
||||
function(idToDelete, next) {
|
||||
|
|
@ -241,5 +241,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
var SAML = new SsoSaml();
|
||||
module.exports = SAML;
|
||||
}(module));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue