IBM Bluemix AppID - how log off / log out?

£可爱£侵袭症+ 提交于 2019-12-24 07:16:34

问题


When using IBM Bluemix App ID, does anyone know how to log out a user? The Node.js server SDK on GitHub sample application and README includes this reference:

const LOGOUT_URL = "/ibm/bluemix/appid/logout";

I have tried various permutations but I haven't been able to find out what URL to use to log out the user (both hostname and extension).

Can anyone help, please?

Many thanks.


回答1:


According to a posting at https://www.ibm.com/developerworks/library/iot-trs-secure-iot-solutions3/index.html , 'There is no explicit "logout" method at time of writing of this article'.

Having done some digging, killing the session will provide logout functionality. This can be achieved in Node.js with the following:

app.get("/logout", function(req, res){
        // Destroy the session
        req.session.destroy();
        //return the main html file
        res.sendfile(__dirname + '/views/index.html');
});



回答2:


To log out the user, you can use the WebAppStrategy on your logout endpoint like the following:

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("/");
});

Look at the Node SDK readme on WebAppStrategy https://github.com/ibm-cloud-security/appid-serversdk-nodejs.



来源:https://stackoverflow.com/questions/43615407/ibm-bluemix-appid-how-log-off-log-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!