I have an HTML application.
Some pages have to run websockets to connect to a server running an Asp.Net application and send/receive some messages through Websocket.
The websockets server works fine. But anyone can send some requests to the server. I would like my server to be protected and receives only authenticated requests. For example from Javascript in Developer Mode, I can run requests against Websocket server...
So far I'm accepting requests only from my domain as follows but that is not enough :
var webSocketOptions = new WebSocketOptions()
{
KeepAliveInterval = TimeSpan.FromSeconds(120),
};
webSocketOptions.AllowedOrigins.Add("https://example.com");
webSocketOptions.AllowedOrigins.Add("https://www.example.com");
app.UseWebSockets(webSocketOptions);
Is there any way to authenticate Websocket requests ? Or for example allow only legitimate users send requests to the WS server ?
Thanks.