【问题标题】:passport-saml strategy implementaion in nodejsnodejs中的passport-saml策略实现
【发布时间】:2018-06-30 03:34:18
【问题描述】:

我正在使用passport-saml 进行身份验证。为此我已经安装了

npm install passport passport-saml --save

我已经使用这个博客 Auth0 创建了我的 IDP。

初始化护照和定义的saml策略

app.use(passport.initialize());

passport.use(new passportSaml.Strategy(
        {
            path: "/login/callback",
            entryPoint: "https://qpp1.auth0.com/samlp/bZVOM5KQmhyir5xEYhLHGRAQglks2AIp",
            issuer: "passport-saml",
            // Identity Provider's public key
            cert: fs.readFileSync("./src/cert/idp_cert.pem", "utf8"),
        },
        (profile, done) => {
            console.log("Profile : ",profile);
            let user = new Profile({ id: profile["nameID"], userName: profile["http://schemas.auth0.com/nickname"] });
            return done(null, user);
        }
    ));

这里是路线

app.get("/login",
    passport.authenticate("saml", (err, profile) => {
        // control will not come here ????   
        console.log("Profile : ", profile);
    })
);
app.post("/login/callback",
         (req, res, next) => {
            passport.authenticate("saml", { session: false }, (err, user) => {
                req.user = user;
                next();
            })(req, res, next);
         },
         RouteHandler.sendResponse
);

现在一切正常,但我有一些问题

1)issuer在saml策略中是什么意思

2) 为什么我需要在两个 URL 映射中使用 passport.authenticate。我不明白为什么/login/callback 请求中需要它。甚至控制不会到我在passport.authenticate方法中传递的/login请求的功能?

这背后的逻辑是什么?这在任何情况下都有用吗?

【问题讨论】:

    标签: node.js authentication passport.js passport-saml


    【解决方案1】:

    我们刚刚完成了多租户护照-saml 实施。通过我们的研究、测试和开发周期,我们发现了以下几点:

    1. “issuer”似乎映射到 SAML 中的 EntityID 请求/响应断言。
    2. GET /login 上的身份验证为您提供 SP 启动的流程 能力。将向 IdP 发送 AuthNRequest。用户将 验证(或已验证),然后 IdP 将 对断言消费者服务端点进行回调。在 您的案例 POST /login/callback 进行身份验证。邮政 /login/callback 端点是 IdP 发起的 SAML 流。

    为了了解如何与我们的应用程序集成,我们从 IdP 启动的流和 ACS 回调开始。我们与之集成的第一个客户是成功的。然而,他们问的第一个问题是,我们应该为 SP 发起的流使用什么 URL? :-) 我很快就能让 SP 启动的流程开始工作。

    我已经使用 Salesforce 开发人员和 SSO Circle 作为测试 IdP 对此进行了测试。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-01
      • 1970-01-01
      • 2015-01-03
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 2020-01-31
      • 2017-02-25
      相关资源
      最近更新 更多