我已经使用 passport-saml 在节点 api 中实现了 ADFS SSO。登录有效,但是当我不放弃任何凭据并提交登录表单时,ADFS 服务器返回以下错误:
“SAML 提供者返回响应者错误:未指定”
当我之后再次尝试登录时,ADFS 直接返回到回调 url,并且再次弹出错误。
passport.use('saml', new SAMLStrategy({
entryPoint: adfsEntryPoint,
issuer: '{adfs-url}/login/adfs',
callbackUrl: '{adfs-url}/login/adfs/callback',
cert: "{CERT}",
authnContext:'http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/windows',
identifierFormat: null,
signatureAlgorithm: 'sha256'
}, (profile, done) => {
const upn = profile["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"];
const windowsAccountName = profile["http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname"];
const user = new userModel.User(upn, "user");
user.enabled = true;
return done(null, user);
}));
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser(function (user, done) {
done(null, user);
});
router.get('/auth/adfs', passport.authenticate('saml', { failureRedirect: "/" }), (req, res) => {
res.redirect('/');
});
router.get('/auth/adfs/callback', passport.authenticate('saml', { failureRedirect: "/" }), (req, res) => {
res.redirect('/');
});