Protecting endpoints with a custom authorization policy

At the moment, any authenticated user can update or delete questions. We are going to implement and use a custom authorization policy and use it to enforce that only the author of the question can do these operations. Let's carry out the following steps:

  1. In the Startup class, let's add the following using statements:
using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Authorization;using QandA.Authorization;

Note that the reference to the QandA.Authorization namespace doesn't exist yet. We'll implement this in a later step.

  1. We'll need to eventually call an Auth0 web service, so let's make the HTTP client available in the ConfigureServices method. Let's also add an authorization ...

Get ASP.NET Core 3 and React 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.