问题
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