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 master_config = {};
|
||||||
var samlObj;
|
var samlObj;
|
||||||
|
|
||||||
var SAML = {
|
Class SsoSaml {
|
||||||
|
|
||||||
init: function(params, callback) {
|
init(params, callback) {
|
||||||
|
|
||||||
function render(req, res, next) {
|
function render(req, res, next) {
|
||||||
res.render('admin/plugins/sso-saml', {});
|
res.render('admin/plugins/sso-saml', {});
|
||||||
|
|
@ -41,9 +41,9 @@
|
||||||
|
|
||||||
console.log("[sso-saml] init done");
|
console.log("[sso-saml] init done");
|
||||||
callback();
|
callback();
|
||||||
},
|
}
|
||||||
|
|
||||||
get_config: function(options, callback) {
|
get_config(options, callback) {
|
||||||
meta.settings.get('sso_saml', function(err, settings) {
|
meta.settings.get('sso_saml', function(err, settings) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(null, options);
|
return callback(null, options);
|
||||||
|
|
@ -52,9 +52,9 @@
|
||||||
options.sso_saml = settings;
|
options.sso_saml = settings;
|
||||||
callback(null, options);
|
callback(null, options);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
initSaml: function() {
|
initSaml {
|
||||||
if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
||||||
console.log("creating samlObj");
|
console.log("creating samlObj");
|
||||||
samlObj = new passportSAML({
|
samlObj = new passportSAML({
|
||||||
|
|
@ -148,9 +148,9 @@
|
||||||
else {
|
else {
|
||||||
console.log("[sso-saml] Cannot create samlObj");
|
console.log("[sso-saml] Cannot create samlObj");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
getStrategy: function(strategies, callback) {
|
getStrategy(strategies, callback) {
|
||||||
|
|
||||||
this.initSaml();
|
this.initSaml();
|
||||||
|
|
||||||
|
|
@ -168,9 +168,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, strategies);
|
callback(null, strategies);
|
||||||
},
|
}
|
||||||
|
|
||||||
login: function(userdata, callback) {
|
login(userdata, callback) {
|
||||||
|
|
||||||
SAML.getUidBySAMLId(userdata.username, function(err, uid) {
|
SAML.getUidBySAMLId(userdata.username, function(err, uid) {
|
||||||
if(err) {
|
if(err) {
|
||||||
|
|
@ -204,18 +204,18 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
getUidBySAMLId: function(samlid, callback) {
|
getUidBySAMLId(samlid, callback) {
|
||||||
db.getObjectField('samlid:uid', samlid, function(err, uid) {
|
db.getObjectField('samlid:uid', samlid, function(err, uid) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
callback(null, uid);
|
callback(null, uid);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
addMenuItem: function(custom_header, callback) {
|
addMenuItem(custom_header, callback) {
|
||||||
custom_header.authentication.push({
|
custom_header.authentication.push({
|
||||||
"route": constants.admin.route,
|
"route": constants.admin.route,
|
||||||
"icon": constants.admin.icon,
|
"icon": constants.admin.icon,
|
||||||
|
|
@ -223,9 +223,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(null, custom_header);
|
callback(null, custom_header);
|
||||||
},
|
}
|
||||||
|
|
||||||
deleteUserData: function(uid, callback) {
|
deleteUserData(uid, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
async.apply(user.getUserField, uid, 'samlid'),
|
async.apply(user.getUserField, uid, 'samlid'),
|
||||||
function(idToDelete, next) {
|
function(idToDelete, next) {
|
||||||
|
|
@ -241,5 +241,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var SAML = new SsoSaml();
|
||||||
module.exports = SAML;
|
module.exports = SAML;
|
||||||
}(module));
|
}(module));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue