I’m using the SignalR Javascript client and ASP.NET ServiceHost. I need the SignalR hubs and callbacks to only be accessible to logged in users. I also need to be able to get the identity of the currently logged in user from the Hub using the FormsIdentity from HttpContext.Current.User.
- How do I secure the hub’s so that only authenticated users can use SignalR?
- How do I get the identity of the currently logged in user from the Hub?
You should use the
this.Context.User.Identitythat is available from the Hub. See a related questionEDIT: To stop unauthenticated users:
EDIT #2:
This might be better, just return a message