Open tarrencev opened 4 years ago
@tarrencev Maybe we can add Authentication Handler
at https://github.com/cloudwebrtc/go-protoo/blob/master/server/websocket_server.go#L48?
look like this:
cfg.WebSocketServerConfig{
....
AuthenticationHandler: func(authinfo interface{}) (bool, error) {
ok, err := jwt.AuthCheck(authinfo)
return ok, err
}
}
...
func (server *WebSocketServer) handleWebSocketRequest(writer http.ResponseWriter, request *http.Request) {
authinfo := request.GetAuthInfo()
if ok, err := server.cfg.AuthenticationHandler(authinfo); !ok {
// Authenticating failed!
writer.WriteCode(403)
return
}
}
I thought about this more and i think it makes more sense to just implement the server in Ion directly
Is it possible to return an authentication error from a consuming library? I am working on adding JWT auth to Ion and we need to be able to reject the socket connection (return 403). It seems since the response writer is not accessible this is not possible.