38 Using ASP.NET Core Identity

 

This chapter covers

  • Setting up ASP.NET Core Identity in an ASP.NET Core project
  • Creating the ASP.NET Core Identity database
  • Managing user accounts and roles

ASP.NET Core Identity is an API from Microsoft to manage users in ASP.NET Core applications and includes support for integrating authentication and authorization into the request pipeline.

ASP.NET Core Identity is a toolkit with which you create the authorization and authentication features an application requires. There are endless integration options for features such as two-factor authentication, federation, single sign-on, and account self-service. There are options that are useful only in large corporate environments or when using cloud-hosted user management.

ASP.NET Core Identity has evolved into its own framework and is too large for me to cover in detail in this book. Instead, I have focused on the parts of the Identity API that intersect with web application development, much as I have done with Entity Framework Core. In this chapter, I show you how to add ASP.NET Core Identity to a project and explain how to consume the ASP.NET Core Identity API to create tools to perform basic user and role management. In chapter 39, I show you how to use ASP.NET Core Identity to authenticate users and perform authorization. Table 38.1 puts ASP.NET Core Identity in context.

38.1 Preparing for this chapter

38.2 Preparing the project for ASP.NET Core Identity

38.2.1 Preparing the ASP.NET Core Identity database

38.2.2 Configuring the application

38.2.3 Creating and applying the Identity database migration

38.3 Creating user management tools

38.3.1 Preparing for user management tools

38.3.2 Enumerating user accounts

38.3.3 Creating users

38.3.4 Editing users

38.3.5 Deleting users

38.4 Creating role management tools

38.4.1 Preparing for role management tools

38.4.2 Enumerating and deleting roles

38.4.3 Creating roles

38.4.4 Assigning role membership

Summary