Node.js Passport-saml 重定向到 localhost :3000/login/callback all the time

标签 node.js passport.js saml saml-2.0

我正在使用 www.npmjs.org/package/passport-saml 中的 SAML 教程。我是 SAML 的初学者。

教程说

The SAML identity provider will redirect you to the URL provided by the path configuration

我已经有一个 OpenIdp 帐户。看来我可以成功登录,但重定向 URL 总是将我发送到 localhost:3000/login/callback ,这在我的代码中不存在,因为我将 'path' 更改为'/users/login-user-db-saml''www.passporttoken.com:1234/users/login-user-db-saml' (两者都没有不起作用,但仍然将我发送到默认的登录/回调)。

我有下面的代码。我做错了什么?

/**start FOR SAML**/
passport.use(new SamlStrategy(
    {
        path: '/users/login-user-db-saml',
        entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
        issuer: 'passport-saml'
    },
    function(profile, done) {
        findByEmail(profile.email, function(err, user) {
            if (err) {
                return done(err);
            }
            return done(null, user);
        });
    })
);

app.post('/users/login-user-db-sam',
    passport.authenticate('saml', { failureRedirect: '/users/login-user-saml', failureFlash: true }),
    function(req, res) {
        res.redirect('/');
    }
);

app.get('/users/login-user-saml',
    passport.authenticate('saml', { failureRedirect: '/users/login-user-saml', failureFlash: true }),
    function(req, res) {
        res.redirect('/');
    }
);
/**End for SAML**/

最佳答案

我从 SAML 配置中删除了“路径”,而是使用带有指定回调的完整路径的“callbackUrl”。我还设置了“发行人”,如下所示:

    saml : {
      entryPoint : 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
      issuer : 'http://192.168.56.101:3000',
      callbackUrl : 'http://192.168.56.101:3000/login/callback' 
    }

您还应该在 OpenIdP 的元数据配置页面上配置您的 SAML SP:https://openidp.feide.no/simplesaml/module.php/metaedit/edit.php - 将 SAML 2.0 选项卡上的 AssertionConsumerServiceURL 设置为您的回调 Url,并将实体 ID 设置为上面的“颁发者”。

关于Node.js Passport-saml 重定向到 localhost :3000/login/callback all the time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21870767/

相关文章:

javascript - 在index.html 上创建node.js 服务器时未呈现扩展文件

node.js - docpad运行错误未定义.docpad.cson

deserialization - Passport.socketio 的 Passport "Failed to deserialize user out of session"。但是我的主应用程序中的 Passport (具有相同的 key )反序列化得很好

sharepoint - 用于 SharePoint 2010 身份验证的 SAML

node.js - 如何使用 Express 服务器/ react 客户端在另一个域中 SSO 并重定向到另一个域?

single-sign-on - OIDC IdP 提供商之上的代理,用于接受来自服务提供商的 SSO SAML 请求

javascript - 如何在我的 Node + Express 应用程序中设置路由以传递身份验证方法?

javascript - nodejs中的SHA256withRSA签名验证每次都返回false

javascript - 在passport.js中使用Facebook登录,无需设置密码

javascript - req.user 和 Is Authenticated 始终为 false