未调用护照回调

Passport callback not being called

在尝试实施与护照相同的身份验证方法时,我遇到了障碍。传递给 passport.authenticated 函数的回调函数未被调用。

router.post("/saml/callback",
    function (req, res, next) {
        req.body.SAMLResponse = req.body.SAMLResponse.replace(/[\n\r]/g, "");
        next();
    },
    function (req, res, next) {
        console.log("Calling passport handler");
        console.log(req.body);
        try {
            const response = passport.authenticate("saml",
                {
                    failureRedirect: "/saml/error",
                    failureFlash: true
                }, (error, user, info) => {
                    console.log(error, user, info);
                    next();
                })(req, res, next);
            console.log(response);
        } catch(e) {
            console.log(e);
        }
        console.log("Line after passport handler");
    },
    function (req, res) {
        res.redirect("/saml/success");
    }
);

我的 Express 应用程序在输入此方法时挂起,但仅使用 1 个特定的 saml 提供程序(使用 https://samltest.id 作为测试提供程序确实使用完全相同的代码)。似乎在这个验证方法中发生了错误,但我无法在我的生活中找到这个错误。

如何获取此回调中的错误。

日志输出:

Calling passport handler
{SAMLResponse: 'base64encoded saml response'}
undefined
Line after passport handler
Error: connect ETIMEDOUT ip:443

问题根本不在这段代码中,而是在 saml 提供程序的启动中。

我在 Strategy({cert: function(callback)....}); 中有一个回调函数,它试图为 saml 响应获取签名证书。然而,IDP 无法从我的 SP 访问,因为它是测试服务器,因此从未调用过回调。

TL;DR;如果您在 Strategy 定义中使用 cert 键;并且所述键使用回调,检查是否调用了该回调!