最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

未调用Passport回调

运维笔记admin14浏览0评论

未调用Passport回调

未调用Passport回调

[在尝试实施相同的护照认证方法时,我遇到了障碍。传递给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");
    }
);

我的快速应用程序在输入此方法时挂起,但仅使用1个特定的saml提供程序(使用)。似乎此身份验证方法中发生了错误,但我无法实时发现此错误。

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

日志输出:

打电话给护照管理员{SAMLResponse: 'base64encoded saml response'}未定义护照办理人后一行错误:连接ETIMEDOUT ip:443

回答如下:

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

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

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论