Keycloak authentication on socket io

半世苍凉 提交于 2020-12-12 02:40:07

问题


I am trying to find out how to authenticate a socket io connection with keycloak. I have used successfully keycloak.protect() function as a middle ware in express, but I am at loss when it comes to socket io. I want something similar to this.

app.get("/examples",keycloak.protect(), function(req, res) {
    res.sendFile(path.join(__dirname, '../production/examples.html'));
});

For example to this :

io.on('connection', keycloak.protect(), function(socket){

    socket.on('disconnect', function(){
        console.log('user disconnected');
    });
    ...
    io.emit('terminal',user_name);

});

来源:https://stackoverflow.com/questions/50001685/keycloak-authentication-on-socket-io

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