使用 IBM Bluemix App ID 时,有人知道如何注销用户吗?GitHub 示例应用程序和 README 上的 Node.js 服务器 SDK 包含以下参考:
const LOGOUT_URL = "/ibm/bluemix/appid/logout";
我尝试了各种排列,但我无法找出用于注销用户的 URL(主机名和扩展名)。
有人可以帮忙吗?
非常感谢。
根据https://www.ibm.com/developerworks/library/iot-trs-secure-iot-solutions3/index.html上的帖子,“在撰写本文时没有明确的“注销”方法” .
完成一些挖掘后,终止会话将提供注销功能。这可以在 Node.js 中通过以下方式实现:
app.get("/logout", function(req, res){
// Destroy the session
req.session.destroy();
//return the main html file
res.sendfile(__dirname + '/views/index.html');
});
要注销用户,您可以在注销端点上使用 WebAppStrategy,如下所示:
app.get("/logout", function(req, res, next) {
WebAppStrategy.logout(req);
// If you chose to store your refresh-token, don't forgot to clear it also in logout:
res.clearCookie("refreshToken");
res.redirect("/");
});
查看 WebAppStrategy https://github.com/ibm-cloud-security/appid-serversdk-nodejs上的 Node SDK 自述文件。