Applying Authentication in SignalR

Learn to apply authentication in SignalR applications.

Overview

We'll first enable authentication middleware on our SignalR server application. Next, we'll apply access restrictions to the SignalR Hub, so only authenticated users would be allowed to access it. Finally, we'll ensure that our clients are authenticated.

Setting up authentication on SignalR server

To apply authentication to our SignalR Hub, we first need to configure and enable authentication middleware. Before we do this, we need to ensure that the JwtBearer and OpenIdConnect packages have been added to our SignalRServer project. To add them, we can either locate and install them via the NuGet package manager of our IDE, or execute the following commands inside the project folder:

Get hands-on with 1200+ tech skills courses.