diff --git a/library.js b/library.js index d6b696d..3b8297a 100644 --- a/library.js +++ b/library.js @@ -38,39 +38,41 @@ master_config = options; }); - samlObj = new passportSAML({ - path: master_config.callback_path, - entryPoint: master_config.idp_entry_point, - issuer: master_config.issuer, - callbackUrl: nconf.get('url') + master_config.callback_path, - disableRequestedAuthnContext: true, - identifierFormat: null - }, - function(profile, done) { - console.log("[sso-saml] profile, ", profile); - var user = { - nameID: profile.nameID, - nameIDFormat: profile.nameIDFormat, - sn: profile['urn:oid:2.5.4.4'], // sn - //sn: profile.sn, - cn: profile['urn:oid:2.5.4.42'], // givenname - //cn: profile.cn, - //mail: profile.mail, - //eduPersonAffiliation: profile.eduPersonAffiliation, - email: profile.mail, - //email: profile.email, - username: profile['urn:oid:1.3.6.1.4.1.5923.1.1.1.2'], // eduPersonNickname - //username: profile.eduPersonNickname - }; + if (master_config.idp_entry_point && master_config.callback_path && master_config.issuer && master_config.metadata) { + samlObj = new passportSAML({ + path: master_config.callback_path, + entryPoint: master_config.idp_entry_point, + issuer: master_config.issuer, + callbackUrl: nconf.get('url') + master_config.callback_path, + disableRequestedAuthnContext: true, + identifierFormat: null + }, + function(profile, done) { + console.log("[sso-saml] profile, ", profile); + var user = { + nameID: profile.nameID, + nameIDFormat: profile.nameIDFormat, + sn: profile['urn:oid:2.5.4.4'], // sn + //sn: profile.sn, + cn: profile['urn:oid:2.5.4.42'], // givenname + //cn: profile.cn, + //mail: profile.mail, + //eduPersonAffiliation: profile.eduPersonAffiliation, + email: profile.mail, + //email: profile.email, + 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) { - if (err) { - return done(err); - } - done(null, user); - }); - } - ); + SAML.login(user,function(err, user) { + if (err) { + return done(err); + } + done(null, user); + }); + } + ); + } console.log("[sso-saml] samlObj", samlObj);