passport.js
var
fs = require('fs')
, passport = require('passport')
, SamlStrategy = require('passport-saml').Strategy;
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
passport.use(new SamlStrategy(
{
entryPoint: 'https://<ADFS Host>/adfs/ls/',
issuer: 'https://<SP_HOST>:<SP_PORT>/',
callbackUrl: 'https://<SP_HOST>:<SP_PORT>/postResponse',
//Private key for the SP machine
privateCert: fs.readFileSync('./bin/ssl/key.pem', 'utf-8'),
cert: fs.readFileSync('ADFS-ServerPub.cer', 'utf-8'),
// other authn contexts are available e.g. windows single sign-on
authnContext: 'http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password',
// this is configured under the Advanced tab in AD FS relying party
signatureAlgorithm: 'sha256'
},
function(profile, done) {
return done(null,
{
upn: profile['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn'],
// e.g. if you added a Group claim
group: profile['http://schemas.xmlsoap.org/claims/Group']
});
}
));
module.exports = passport;
在显示ADFS登录页面并为其提供登录凭据后,出现以下错误:
SAML提供程序返回了响应者错误:未指定 错误:SAML提供程序返回了响应者错误:未指定 在C:\ LexTest \ node_modules \ passport-saml \ lib \ passport-saml \ saml.js:662:31 在_fulfilled(C:\ LexTest \ node_modules \ q \ q.js:854:54) 在C:\ LexTest \ node_modules \ q \ q.js:883:30 在Promise.promise.promiseDispatch(C:\ LexTest \ node_modules \ q \ q.js:816:13) 在C:\ LexTest \ node_modules \ q \ q.js:570:49 在runSingle(C:\ LexTest \ node_modules \ q \ q.js:137:13) 刷新时(C:\ LexTest \ node_modules \ q \ q.js:125:13) 在process._tickCallback(internal / process / next_tick.js:61:11)