Authorization middleware

Now that we've designated which of our resources require to use authorization to be accessed, it's time to see what that authorization step looks like in our code. For this application, we'll be taking advantage of JWT bearer token authentication. To leverage this, we will be going to our Startup.cs file and modifying the services we've configured to use the appropriate authentication scheme.

Thanks to its open source distribution and wide support, the Microsoft.AspNetCore and Microsoft.IdentityModel namespaces support JWT token libraries right out of the box. This will make defining our authentication behavior much easier. We'll invoke the AddAuthentication() method on IServicesCollection and apply the default JWT ...

Get Hands-On Network Programming with C# and .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.