debugging
This commit is contained in:
parent
4de05d0c74
commit
7f50e97769
1 changed files with 80 additions and 79 deletions
159
library.js
159
library.js
|
|
@ -55,99 +55,100 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
initSaml() {
|
initSaml() {
|
||||||
if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
console.log("[sso-saml] initSaml");
|
||||||
console.log("creating samlObj");
|
//if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) {
|
||||||
samlObj = new passportSAML({
|
// console.log("creating samlObj");
|
||||||
path: master_config.callback_path,
|
// samlObj = new passportSAML({
|
||||||
entryPoint: master_config.idp_entry_point,
|
// path: master_config.callback_path,
|
||||||
issuer: master_config.issuer,
|
// entryPoint: master_config.idp_entry_point,
|
||||||
callbackUrl: nconf.get('url') + master_config.callback_path,
|
// issuer: master_config.issuer,
|
||||||
disableRequestedAuthnContext: true,
|
// callbackUrl: nconf.get('url') + master_config.callback_path,
|
||||||
identifierFormat: null
|
// disableRequestedAuthnContext: true,
|
||||||
},
|
// identifierFormat: null
|
||||||
function(profile, done) {
|
// },
|
||||||
console.log("[sso-saml] profile, ", profile);
|
// function(profile, done) {
|
||||||
var user = {
|
// console.log("[sso-saml] profile, ", profile);
|
||||||
nameID: profile.nameID,
|
// var user = {
|
||||||
nameIDFormat: profile.nameIDFormat,
|
// nameID: profile.nameID,
|
||||||
sn: profile['urn:oid:2.5.4.4'], // sn
|
// nameIDFormat: profile.nameIDFormat,
|
||||||
//sn: profile.sn,
|
// sn: profile['urn:oid:2.5.4.4'], // sn
|
||||||
cn: profile['urn:oid:2.5.4.42'], // givenname
|
// //sn: profile.sn,
|
||||||
//cn: profile.cn,
|
// cn: profile['urn:oid:2.5.4.42'], // givenname
|
||||||
//mail: profile.mail,
|
// //cn: profile.cn,
|
||||||
//eduPersonAffiliation: profile.eduPersonAffiliation,
|
// //mail: profile.mail,
|
||||||
email: profile.mail,
|
// //eduPersonAffiliation: profile.eduPersonAffiliation,
|
||||||
//email: profile.email,
|
// email: profile.mail,
|
||||||
username: profile['urn:oid:1.3.6.1.4.1.5923.1.1.1.2'], // eduPersonNickname
|
// //email: profile.email,
|
||||||
//username: profile.eduPersonNickname
|
// username: profile['urn:oid:1.3.6.1.4.1.5923.1.1.1.2'], // eduPersonNickname
|
||||||
};
|
// //username: profile.eduPersonNickname
|
||||||
|
// };
|
||||||
|
|
||||||
SAML.login(user,function(err, user) {
|
// SAML.login(user,function(err, user) {
|
||||||
if (err) {
|
// if (err) {
|
||||||
return done(err);
|
// return done(err);
|
||||||
}
|
// }
|
||||||
done(null, user);
|
// done(null, user);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (samlObj){
|
//if (samlObj){
|
||||||
|
|
||||||
if (master_config.metadata) {
|
// if (master_config.metadata) {
|
||||||
params.router.get(master_config.metadata, function(req, res) {
|
// params.router.get(master_config.metadata, function(req, res) {
|
||||||
if (master_config.server_crt){
|
// if (master_config.server_crt){
|
||||||
var cert = fs.readFileSync(master_config.server_crt, 'utf-8');
|
// var cert = fs.readFileSync(master_config.server_crt, 'utf-8');
|
||||||
res.header("Content-Type", "application/xml");
|
// res.header("Content-Type", "application/xml");
|
||||||
res.send(samlObj.generateServiceProviderMetadata(cert))
|
// res.send(samlObj.generateServiceProviderMetadata(cert))
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
res.send("No servercrt specified. Please enter it at nodebb admin panel.");
|
// res.send("No servercrt specified. Please enter it at nodebb admin panel.");
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
params.router.post(master_config.callback_path,
|
// params.router.post(master_config.callback_path,
|
||||||
passport.authenticate('saml'),
|
// passport.authenticate('saml'),
|
||||||
function(req, res, next){
|
// function(req, res, next){
|
||||||
if (master_config.login_redirect_url){
|
// if (master_config.login_redirect_url){
|
||||||
res.redirect(master_config.login_redirect_url);
|
// res.redirect(master_config.login_redirect_url);
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
res.redirect("/");
|
// res.redirect("/");
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (master_config.logout_url) {
|
// if (master_config.logout_url) {
|
||||||
|
|
||||||
params.router.get(master_config.logout_url,function(req,res){
|
// params.router.get(master_config.logout_url,function(req,res){
|
||||||
if (req.user && parseInt(req.user.uid, 10) > 0) {
|
// if (req.user && parseInt(req.user.uid, 10) > 0) {
|
||||||
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
// winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
||||||
|
|
||||||
var ws = module.parent.require('./socket.io');
|
// var ws = module.parent.require('./socket.io');
|
||||||
ws.logoutUser(req.user.uid);
|
// ws.logoutUser(req.user.uid);
|
||||||
|
|
||||||
req.logout();
|
// req.logout();
|
||||||
|
|
||||||
if (master_config.logout_redirect_url){
|
// if (master_config.logout_redirect_url){
|
||||||
res.redirect(master_config.logout_redirect_url);
|
// res.redirect(master_config.logout_redirect_url);
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
res.redirect("/");
|
// res.redirect("/");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
//}
|
||||||
else {
|
//else {
|
||||||
console.log("[sso-saml] Cannot create samlObj");
|
// console.log("[sso-saml] Cannot create samlObj");
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
getStrategy(strategies, callback) {
|
getStrategy(strategies, callback) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue