Sun*_*arg 6 authentication node.js passport.js passport-saml
我passport-saml用于身份验证。为此,我已安装
npm install passport passport-saml --save
Run Code Online (Sandbox Code Playgroud)
我已经使用这个博客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);
}
));
Run Code Online (Sandbox Code Playgroud)
这是路线
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
);
Run Code Online (Sandbox Code Playgroud)
现在这工作正常,但我有一些问题
1)issuersaml策略是什么意思
2) 为什么我需要passport.authenticate在两个 URL 映射中使用。我不明白为什么在/login/callback请求中需要它。甚至控制不会来到/login我在passport.authenticate方法中传递的请求函数?
这背后的逻辑是什么?这在任何情况下都有用吗?
小智 8
我们刚刚完成了一个多租户的护照-saml 实施。通过我们的研究、测试和开发周期,我们发现了以下内容:
为了了解如何与我们的应用程序集成,我们从 IdP 启动的流与 ACS 回调开始。我们整合的第一个客户是成功的。然而,他们问的第一个问题是,我们应该为 SP 启动的流使用什么 URL?:-) 我很快就能让 SP 启动的流程工作起来。
我已经使用 Salesforce 开发人员和 SSO Circle 作为测试 IdP 对此进行了测试。
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
7323 次 |
| 最近记录: |