Enabling the identity infrastructure 

Authentication and authorization affect the way that the ASP.NET Core request pipeline is defined. Your Web API needs to check each request to see if it is authenticated, and then see if the requested action is authorized for the authenticated user. If any of these steps fail, we want the API to respond with a meaningful response. To make the necessary modifications to the Web API pipeline, we need to enable the identity infrastructure in the application's startup class. Here are the steps we perform to enable identities in the GiveNTake application:

  1. Add the following lines to the ConfigureService method:
    services.AddIdentity<User, IdentityRole>()        .AddEntityFrameworkStores<GiveNTakeContext>() .AddDefaultTokenProviders(); ...

Get Hands-On Full-Stack Web Development with ASP.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.